-
Notifications
You must be signed in to change notification settings - Fork 8
/
UnitTest.py
31 lines (22 loc) · 914 Bytes
/
UnitTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import unittest
from unittest.mock import Mock, patch
import TargetAPI as Target
import SpoonacularAPI as Spoonacular
class TestTargetAPI(unittest.TestCase):
@patch('TargetAPI.TargetCart')
def test_location(self, mock_get):
mock_get.storeID = "935"
self.assertEqual(mock_get.storeID, "935")
def test_query(self):
result = Target.QueryTarget("936", "Bacon")
self.assertIsNot(result.itemName, "")
class TestSpoonacular(unittest.TestCase):
def test_recipes(self):
recipes = Spoonacular.RecipeBook("American", "burger")
self.assertIsNot(len(recipes.recipes.get("results")), 0)
for recipe in recipes.recipeBook.values():
self.assertIsNot(len(recipe.ingredients), 0)
for ingredient in recipe.ingredients.values():
self.assertIsNotNone(ingredient.name)
if __name__ == '__main__':
unittest.main()