Skip to content

Commit 6ba764d

Browse files
author
codedawi
committed
✅ unittests location service interface
1 parent 955a391 commit 6ba764d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/test_location_service.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import pytest
2+
3+
from app.services.location import LocationService
4+
5+
class GoodLocationService(LocationService):
6+
"""Valid LocationService Class."""
7+
async def get_all(self):
8+
"""
9+
Gets and returns all of the locations.
10+
"""
11+
return [True, True]
12+
13+
async def get(self, id): # pylint: disable=redefined-builtin,invalid-name
14+
"""
15+
Gets and returns location with the provided id.
16+
"""
17+
return id
18+
19+
class BadLocationService(LocationService):
20+
"""Invalid LocationService Class."""
21+
pass
22+
23+
24+
def test_location_service_invalid():
25+
"""Test for location service interface invalid class."""
26+
with pytest.raises(TypeError):
27+
BadLocationService()
28+
29+
30+
def test_location_service_invalid():
31+
"""Test for location service interface valid class."""
32+
good_loc_service = GoodLocationService()
33+
assert all(good_loc_service.get_all())
34+
assert good_loc_service.get(1) == 1
35+

0 commit comments

Comments
 (0)