Skip to content

Commit

Permalink
Asserting that the returned JSON objects are not None.
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Baker <[email protected]>
  • Loading branch information
jbaker0428 committed Jun 15, 2012
1 parent 1ded1e2 commit ed8e9a6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,15 @@ def setUp(self):

def test_categories_get(self):
json_obj, category = api.categories_get(4174)
assert json_obj is not None
assert json_obj == categories_get_ref
assert isinstance(category, OctopartCategory)
assert(category.equals_json(categories_get_ref))
print 'test_categories_get OK'

def test_categories_get_multi(self):
json_obj, categories = api.categories_get_multi([4215,4174,4780])
assert json_obj is not None
assert json_obj == categories_get_multi_ref
for category in categories:
assert isinstance(category, OctopartCategory)
Expand All @@ -144,6 +146,7 @@ def test_categories_get_multi(self):

def test_categories_search(self):
json_obj, categories = api.categories_search(q='resistor')
assert json_obj is not None
assert json_obj == categories_search_ref
for category in categories:
assert isinstance(category[0], OctopartCategory)
Expand All @@ -154,13 +157,15 @@ def test_categories_search(self):

def test_parts_get(self):
json_obj, part = api.parts_get(39619421)
assert json_obj is not None
assert json_obj == parts_get_ref
assert isinstance(part, OctopartPart)
assert(part.equals_json(parts_get_ref))
print 'test_parts_get OK'

def test_parts_get_multi(self):
json_obj, parts = api.parts_get_multi([39619421,29035751,31119928])
assert json_obj is not None
assert json_obj == parts_get_multi_ref
for part in parts:
assert isinstance(part, OctopartPart)
Expand All @@ -171,6 +176,7 @@ def test_parts_get_multi(self):

def test_parts_search(self):
json_obj, parts = api.parts_search(q='resistor', limit=10)
assert json_obj is not None
json_eq(json_obj, parts_search_ref)
for part, highlight in parts:
assert isinstance(part, OctopartPart)
Expand All @@ -182,12 +188,14 @@ def test_parts_search(self):

def test_parts_suggest(self):
json_obj, results = api.parts_suggest(q='sn74f', limit=3)
assert json_obj is not None
json_eq(json_obj, parts_suggest_ref)
assert json_obj['results'] == results
print 'test_parts_suggest OK'

def test_parts_match(self):
json_obj = api.parts_match(manufacturer_name='texas instruments', mpn='SN74LS240N')
assert json_obj is not None
assert json_obj == parts_match_ref

def tearDown(self):
Expand Down

0 comments on commit ed8e9a6

Please sign in to comment.