FIX: Added version changes and IndicoError

This commit is contained in:
Chris Lee
2015-06-09 19:27:59 -04:00
parent 0ccd07a651
commit b1575a2e9f
5 changed files with 16 additions and 12 deletions
+8 -7
View File
@@ -10,6 +10,7 @@ from indicoio import political, sentiment, fer, facial_features, language, image
from indicoio import batch_political, batch_sentiment, batch_fer, batch_facial_features
from indicoio import batch_language, batch_image_features, batch_text_tags
from indicoio import predict_image, predict_text, batch_predict_image, batch_predict_text
from indicoio.utils.errors import IndicoError
DIR = os.path.dirname(os.path.realpath(__file__))
@@ -49,7 +50,7 @@ class BatchAPIRun(unittest.TestCase):
def test_batch_fer_bad_b64(self):
test_data = ["$bad#FI jeaf9(#0"]
self.assertRaises(ValueError, batch_fer, test_data, api_key=self.api_key)
self.assertRaises(IndicoError, batch_fer, test_data, api_key=self.api_key)
def test_batch_fer_good_b64(self):
test_data = ["iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAg5JREFUeNrEV4uNgzAMpegGyAgZgQ3KBscIjMAGx03QEdqbgG5AOwG3AWwAnSCXqLZkuUkwhfYsvaLm5xc7sZ1dIhdtUVjsLZRFTvp+LSaLq8UZ/s+KMSbZCcY5RV9E4QQKHG7QtgeCGv4PFt8WpzkCcztu3TiL0eJgkQmsVFn0MK+LzYkRKEGpG1GDyZdKRdaolhAoJewXnJsO1jtKCFDlChZAFxyJj2PnBRU20KZg7oMlOAENijpi8hwmGkKkZW2GzONtVLA/DxHAhTO2I7MCVBSQ6nGDlEBJDhyVYiUBHXBxzQm0wE4FzPYsGs856dA9SAAP2oENzFYqR6iAFQpHIAUzO/nxnOgthF/lM3w/3U8KYXTwxG/1IgIulF+wPQUXDMl75UoJZIHstRWpaGb8IGYqwBoKlG/lgpzoUEBoj50p8QtVrmHgaaXyC/H3BFC+e9kGFlCB0CtBF7FifQ8D9zjQQHj0pdOM3F1pUBoFKdxtqkMClScHJCSDlSxhHSNRT5K+FaZnHglrz+AGoxZLKNLYH6s3CkkuyJlp58wviZ4PuSCWDXl5hmjZtxcSCGbDUD3gK7EMOZBLCETrgVBF5K0lI5bIZ0wfrYh8NWHIAiNTPHpuTOKpCes1VTFaiNaFdGwPfdmaqlj6LmjJbgoSSfUW74K3voz+/W0oIeB7HWu2s+dfx3N+eLX8CTAAwUmKjK/dHS4AAAAASUVORK5CYII="]
@@ -71,7 +72,7 @@ class BatchAPIRun(unittest.TestCase):
def test_batch_fer_nonexistant_filepath(self):
test_data = ["data/unhappy.png"]
self.assertRaises(ValueError, batch_fer, test_data, api_key=self.api_key)
self.assertRaises(IndicoError, batch_fer, test_data, api_key=self.api_key)
def test_batch_facial_features(self):
@@ -151,18 +152,18 @@ class BatchAPIRun(unittest.TestCase):
self.assertTrue(set(response.keys()) == set(config.TEXT_APIS))
def test_multi_api_bad_api(self):
self.assertRaises(ValueError,
self.assertRaises(IndicoError,
batch_predict_text,
"this shouldn't work",
apis=["sentiment", "somethingbad"])
def test_multi_bad_mixed_api(self):
self.assertRaises(ValueError,
self.assertRaises(IndicoError,
predict_text,
"this shouldn't work",
apis=["fer", "sentiment", "facial_features"])
def test_batch_multi_bad_mixed_api(self):
self.assertRaises(ValueError,
self.assertRaises(IndicoError,
batch_predict_text,
["this shouldn't work"],
apis=["fer", "sentiment", "facial_features"])
@@ -363,7 +364,7 @@ class FullAPIRun(unittest.TestCase):
def test_set_api_key(self):
test_data = 'clearly an english sentence'
self.assertRaises(ValueError,
self.assertRaises(IndicoError,
language,
test_data,
api_key ='invalid_api_key')
@@ -372,7 +373,7 @@ class FullAPIRun(unittest.TestCase):
config.api_key = 'invalid_api_key'
self.assertEqual(config.api_key, 'invalid_api_key')
self.assertRaises(ValueError,
self.assertRaises(IndicoError,
language,
test_data)