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.is_activated = False
|
||||
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._data_paths = ['',
|
||||
self._directory,
|
||||
os.path.join(self._directory, 'data'),
|
||||
self.data_folder]
|
||||
|
||||
data_folder = data_folder or os.getcwd()
|
||||
subdir = os.path.join(data_folder, self.name)
|
||||
|
||||
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))
|
||||
|
||||
@property
|
||||
|
@ -41,7 +41,7 @@ class Sentiment140Plugin(SentimentPlugin):
|
||||
To avoid calling the sentiment140 API, we will mock the results
|
||||
from requests.
|
||||
'''
|
||||
from senpy.test import patch_requests
|
||||
from senpy.testing import patch_requests
|
||||
expected = {"data": [{"polarity": 4}]}
|
||||
with patch_requests(expected) as (request, response):
|
||||
super(Sentiment140Plugin, self).test(*args, **kwargs)
|
||||
|
@ -1,6 +1,6 @@
|
||||
from unittest import TestCase
|
||||
|
||||
from senpy.test import patch_requests
|
||||
from senpy.testing import patch_requests
|
||||
from senpy.client import Client
|
||||
from senpy.models import Results, Plugins, Error
|
||||
from senpy.plugins import AnalysisPlugin
|
||||
|
@ -2,7 +2,7 @@ from unittest import TestCase
|
||||
|
||||
import requests
|
||||
import json
|
||||
from senpy.test import patch_requests
|
||||
from senpy.testing import patch_requests
|
||||
from senpy.models import Results
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user