Skip to content

Commit

Permalink
fixing tests for new pypi release 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
icepick4 committed Jan 29, 2023
1 parent 2046850 commit e8a0142
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
Binary file modified onepyece/__pycache__/interface.cpython-39.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="onepyece",
version="1.0.1",
version="1.1.0",
author="Rémi JARA",
author_email="[email protected]",
description="A package to use the One-Piece API : https://api-onepiece.com/",
Expand Down
Binary file modified tests/__pycache__/test_common.cpython-39.pyc
Binary file not shown.
Binary file modified tests/__pycache__/test_interface.cpython-39.pyc
Binary file not shown.
16 changes: 8 additions & 8 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_url_no_search(self, endpoint="characters"):
url = common.build_url(endpoint)
self.assertEqual(url, "https://api.api-onepiece.com/characters")

def test_url_with_search(self, endpoint="characters", search="id", resource="1"):
def test_url_with_search(self, endpoint="characters", search="id", resource=1):
url = common.build_url(endpoint, search, resource)
self.assertEqual(url, "https://api.api-onepiece.com/characters/1")

Expand All @@ -32,7 +32,7 @@ def test_url_by_title(self, endpoint="episodes", search="title", resource="Je su
url = common.build_url(endpoint, search, resource)
self.assertEqual(url, "https://api.api-onepiece.com/episodes/search/Je%20suis%20Luffy%20!")

def test_url_search_other_id(self, endpoint="boats", search="crew_id", resource="1"):
def test_url_search_other_id(self, endpoint="boats", search="crew_id", resource=1):
url = common.build_url(endpoint, search, resource)
self.assertEqual(url, "https://api.api-onepiece.com/boats/search/crew/1")

Expand All @@ -51,19 +51,19 @@ def test_endpoint_with_wrong_value(self, endpoint="wrong"):
def test_search_no_resource(self, endpoint="characters", search="id"):
self.assertRaises(ValueError, common.check_params, endpoint, search)

def test_search_with_resource(self, endpoint="characters", search="id", resource="1"):
def test_search_with_resource(self, endpoint="characters", search="id", resource=1):
self.assertEqual(common.check_params(endpoint, search, resource), None)

def test_search_with_wrong_value(self, endpoint="characters", search="wrong", resource="1"):
def test_search_with_wrong_value(self, endpoint="characters", search="wrong", resource=1):
self.assertRaises(ValueError, common.check_params, endpoint, search, resource)


class TestConvertName(unittest.TestCase):
def test_convert_name(self, name="Baggy / Le Clown"):
self.assertEqual(common.convert_name(name), "Baggy")
def test_convert_resource(self, name="Baggy / Le Clown"):
self.assertEqual(common.convert_resource(name), "Baggy")

def test_convert_name_with_space(self, name="Baggy / Le Clown "):
self.assertEqual(common.convert_name(name), "Baggy")
def test_convert_resource_with_space(self, name="Baggy / Le Clown "):
self.assertEqual(common.convert_resource(name), "Baggy")


class TestEndpointsSearches(unittest.TestCase):
Expand Down
16 changes: 8 additions & 8 deletions tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@

class TestAPI(unittest.TestCase):
def test_unique_character(self):
api_object = interface.API("characters", "id", "1")
api_object = interface.API("characters", "id", 1)
self.assertIsInstance(api_object, interface.API)
self.assertEqual(api_object.resource, "1")
self.assertEqual(api_object.resource, 1)
self.assertEqual(api_object.id, 1)
self.assertEqual(api_object.french_name, "Monkey D Luffy")

def test_unique_character_with_wrong_resource_id(self):
self.assertRaises(ValueError, interface.API, "characters", "id", "wrong")

def test_unique_character_with_wrong_search(self):
self.assertRaises(ValueError, interface.API, "characters", "wrong", "1")
self.assertRaises(ValueError, interface.API, "characters", "wrong", 1)

def test_unique_character_with_wrong_endpoint(self):
self.assertRaises(ValueError, interface.API, "wrong", "id", "1")
self.assertRaises(ValueError, interface.API, "wrong", "id", 1)

def test_multiple_result(self):
api_object = interface.API("hakis", "name", "Haki")
self.assertIsInstance(api_object, interface.API)
self.assertIsInstance(api_object.results, list)
self.assertEqual(api_object.resource, "Haki")
self.assertRaises(AttributeError, getattr, api_object, "id")
self.assertIsInstance(api_object.results[0], dict)
self.assertEqual(api_object.results[0]["french_name"], "Haki de l'Observation")
self.assertIsInstance(api_object.results[0], interface.API)
self.assertEqual(api_object.results[0].french_name, "Haki de l'Observation")

def test_count_implicit(self):
api_object = interface.API("hakis")
Expand All @@ -49,8 +49,8 @@ def test_iterate_object(self):
api_object = interface.API("crews")
self.assertIsInstance(api_object, interface.API)
for result in api_object:
self.assertIsInstance(result, dict)
self.assertIsInstance(result, interface.API)
# Unique result -> do not iterate
api_object = interface.API("crews", "id", "1")
api_object = interface.API("crews", "id", 1)
self.assertIsInstance(api_object, interface.API)
self.assertRaises(TypeError, iter, api_object)

0 comments on commit e8a0142

Please sign in to comment.