mirror of
https://github.com/gsi-upm/senpy
synced 2024-11-24 17:12:29 +00:00
Change data loading logic. Bugs senpy.testing
This commit is contained in:
parent
7a8abf1823
commit
6832a2816d
@ -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
|
||||||
|
@ -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.testing 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)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from senpy.test import patch_requests
|
from senpy.testing 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
|
||||||
|
@ -2,7 +2,7 @@ from unittest import TestCase
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from senpy.test import patch_requests
|
from senpy.testing import patch_requests
|
||||||
from senpy.models import Results
|
from senpy.models import Results
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user