mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-06-27 16:10:34 +08:00
Add local tests
This commit is contained in:
@@ -3,7 +3,7 @@ from utils import config
|
||||
|
||||
JSON_HEADERS = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||
|
||||
Version, version, __version__, VERSION = ('0.4.4',) * 4
|
||||
Version, version, __version__, VERSION = ('0.4.5',) * 4
|
||||
|
||||
from text.sentiment import political, posneg
|
||||
from text.sentiment import posneg as sentiment
|
||||
@@ -14,6 +14,7 @@ from images.features import image_features
|
||||
|
||||
political = partial(political, config.api_root)
|
||||
sentiment = partial(sentiment, config.api_root)
|
||||
posneg = partial(sentiment, config.api_root)
|
||||
language = partial(language, config.api_root)
|
||||
fer = partial(fer, config.api_root)
|
||||
facial_features = partial(facial_features, config.api_root)
|
||||
|
||||
@@ -3,8 +3,6 @@ from indicoio.utils import config
|
||||
|
||||
JSON_HEADERS = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||
|
||||
Version, version, __version__, VERSION = ('0.4.3',) * 4
|
||||
|
||||
from indicoio.text.sentiment import political, posneg
|
||||
from indicoio.text.sentiment import posneg as sentiment
|
||||
from indicoio.text.lang import language
|
||||
@@ -14,6 +12,7 @@ from indicoio.images.features import image_features
|
||||
|
||||
political = partial(political, config.local_api_root)
|
||||
sentiment = partial(sentiment, config.local_api_root)
|
||||
posneg = partial(sentiment, config.local_api_root)
|
||||
language = partial(language, config.local_api_root)
|
||||
fer = partial(fer, config.local_api_root)
|
||||
facial_features = partial(facial_features, config.local_api_root)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
local_api_root = "http://localhost:9438/"
|
||||
api_root = "http://www.indico.io/api/"
|
||||
api_root = "http://api.indico.io/"
|
||||
@@ -0,0 +1,90 @@
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
|
||||
from indicoio.local import political, sentiment, fer, facial_features, language
|
||||
|
||||
|
||||
class FullAPIRun(unittest.TestCase):
|
||||
|
||||
def test_political(self):
|
||||
political_set = set(['Libertarian', 'Liberal', 'Conservative', 'Green'])
|
||||
test_string = "Guns don't kill people, people kill people."
|
||||
response = political(test_string)
|
||||
|
||||
self.assertTrue(isinstance(response, dict))
|
||||
self.assertEqual(political_set, set(response.keys()))
|
||||
|
||||
def test_posneg(self):
|
||||
posneg_set = set(['Sentiment'])
|
||||
test_string = "Worst song ever."
|
||||
response = sentiment(test_string)
|
||||
|
||||
self.assertTrue(isinstance(response, float))
|
||||
|
||||
def test_good_fer(self):
|
||||
fer_set = set(['Angry', 'Sad', 'Neutral', 'Surprise', 'Fear', 'Happy'])
|
||||
test_face = np.linspace(0,50,48*48).reshape(48,48).tolist()
|
||||
response = fer(test_face)
|
||||
|
||||
self.assertTrue(isinstance(response, dict))
|
||||
self.assertEqual(fer_set, set(response.keys()))
|
||||
|
||||
def test_bad_fer(self):
|
||||
fer_set = set(['Angry', 'Sad', 'Neutral', 'Surprise', 'Fear', 'Happy'])
|
||||
test_face = np.linspace(0,50,56*56).reshape(56,56).tolist()
|
||||
response = fer(test_face)
|
||||
|
||||
self.assertTrue(isinstance(response, dict))
|
||||
self.assertEqual(fer_set, set(response.keys()))
|
||||
|
||||
def test_good_facial_features(self):
|
||||
test_face = np.linspace(0,50,48*48).reshape(48,48).tolist()
|
||||
response = facial_features(test_face)
|
||||
|
||||
self.assertTrue(isinstance(response, list))
|
||||
self.assertEqual(len(response), 48)
|
||||
|
||||
def test_language(self):
|
||||
language_set = set([
|
||||
'English',
|
||||
'Spanish',
|
||||
'Tagalog',
|
||||
'Esperanto',
|
||||
'French',
|
||||
'Chinese',
|
||||
'French',
|
||||
'Bulgarian',
|
||||
'Latin',
|
||||
'Slovak',
|
||||
'Hebrew',
|
||||
'Russian',
|
||||
'German',
|
||||
'Japanese',
|
||||
'Korean',
|
||||
'Portuguese',
|
||||
'Italian',
|
||||
'Polish',
|
||||
'Turkish',
|
||||
'Dutch',
|
||||
'Arabic',
|
||||
'Persian (Farsi)',
|
||||
'Czech',
|
||||
'Swedish',
|
||||
'Indonesian',
|
||||
'Vietnamese',
|
||||
'Romanian',
|
||||
'Greek',
|
||||
'Danish',
|
||||
'Hungarian',
|
||||
'Thai',
|
||||
'Finnish',
|
||||
'Norwegian',
|
||||
'Lithuanian'
|
||||
])
|
||||
language_dict = language('clearly an english sentence')
|
||||
self.assertEqual(language_set, set(language_dict.keys()))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user