Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
senpy
senpy
Commits
6832a281
Commit
6832a281
authored
Jun 15, 2018
by
J. Fernando Sánchez
Browse files
Change data loading logic. Bugs senpy.testing
parent
7a8abf18
Changes
4
Hide whitespace changes
Inline
Side-by-side
senpy/plugins/__init__.py
View file @
6832a281
...
@@ -95,12 +95,22 @@ class Plugin(with_metaclass(PluginMeta, models.Plugin)):
...
@@ -95,12 +95,22 @@ class Plugin(with_metaclass(PluginMeta, models.Plugin)):
self
.
id
=
'plugins/{}_{}'
.
format
(
self
[
'name'
],
self
[
'version'
])
self
.
id
=
'plugins/{}_{}'
.
format
(
self
[
'name'
],
self
[
'version'
])
self
.
is_activated
=
False
self
.
is_activated
=
False
self
.
_lock
=
threading
.
Lock
()
self
.
_lock
=
threading
.
Lock
()
self
.
data_folder
=
data_folder
or
os
.
getcwd
()
self
.
_directory
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)))
self
.
_directory
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)))
self
.
_data_paths
=
[
''
,
self
.
_directory
,
data_folder
=
data_folder
or
os
.
getcwd
()
os
.
path
.
join
(
self
.
_directory
,
'data'
),
subdir
=
os
.
path
.
join
(
data_folder
,
self
.
name
)
self
.
data_folder
]
self
.
_data_paths
=
[
data_folder
,
subdir
,
self
.
_directory
,
os
.
path
.
join
(
self
.
_directory
,
'data'
),
]
if
os
.
path
.
exists
(
subdir
):
data_folder
=
subdir
self
.
data_folder
=
data_folder
self
.
_log
=
logging
.
getLogger
(
'{}.{}'
.
format
(
__name__
,
self
.
name
))
self
.
_log
=
logging
.
getLogger
(
'{}.{}'
.
format
(
__name__
,
self
.
name
))
@
property
@
property
...
...
senpy/plugins/sentiment/sentiment140/sentiment140.py
View file @
6832a281
...
@@ -41,7 +41,7 @@ class Sentiment140Plugin(SentimentPlugin):
...
@@ -41,7 +41,7 @@ class Sentiment140Plugin(SentimentPlugin):
To avoid calling the sentiment140 API, we will mock the results
To avoid calling the sentiment140 API, we will mock the results
from requests.
from requests.
'''
'''
from
senpy.test
import
patch_requests
from
senpy.test
ing
import
patch_requests
expected
=
{
"data"
:
[{
"polarity"
:
4
}]}
expected
=
{
"data"
:
[{
"polarity"
:
4
}]}
with
patch_requests
(
expected
)
as
(
request
,
response
):
with
patch_requests
(
expected
)
as
(
request
,
response
):
super
(
Sentiment140Plugin
,
self
).
test
(
*
args
,
**
kwargs
)
super
(
Sentiment140Plugin
,
self
).
test
(
*
args
,
**
kwargs
)
...
...
tests/test_client.py
View file @
6832a281
from
unittest
import
TestCase
from
unittest
import
TestCase
from
senpy.test
import
patch_requests
from
senpy.test
ing
import
patch_requests
from
senpy.client
import
Client
from
senpy.client
import
Client
from
senpy.models
import
Results
,
Plugins
,
Error
from
senpy.models
import
Results
,
Plugins
,
Error
from
senpy.plugins
import
AnalysisPlugin
from
senpy.plugins
import
AnalysisPlugin
...
...
tests/test_test.py
View file @
6832a281
...
@@ -2,7 +2,7 @@ from unittest import TestCase
...
@@ -2,7 +2,7 @@ from unittest import TestCase
import
requests
import
requests
import
json
import
json
from
senpy.test
import
patch_requests
from
senpy.test
ing
import
patch_requests
from
senpy.models
import
Results
from
senpy.models
import
Results
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment