Commit 6832a281 authored by J. Fernando Sánchez's avatar J. Fernando Sánchez

Change data loading logic. Bugs senpy.testing

parent 7a8abf18
......@@ -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)
......
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment