54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
"""
|
|
Contract Tests: Coverage Check API
|
|
|
|
Endpoint: /mascotas/api/v1/coverage/check/
|
|
App: mascotas
|
|
|
|
Used to check if a location has veterinary coverage before proceeding with turnero.
|
|
"""
|
|
|
|
from ..base import ContractTestCase
|
|
from ..endpoints import Endpoints
|
|
|
|
|
|
class TestCoverageCheck(ContractTestCase):
|
|
"""GET /mascotas/api/v1/coverage/check/"""
|
|
|
|
def test_with_coordinates_returns_200(self):
|
|
"""Coverage check should accept lat/lng parameters"""
|
|
response = self.get(Endpoints.COVERAGE_CHECK, params={
|
|
"lat": -34.6037,
|
|
"lng": -58.3816,
|
|
})
|
|
|
|
self.assert_status(response, 200)
|
|
|
|
def test_returns_coverage_boolean(self):
|
|
"""Coverage check should return coverage boolean"""
|
|
response = self.get(Endpoints.COVERAGE_CHECK, params={
|
|
"lat": -34.6037,
|
|
"lng": -58.3816,
|
|
})
|
|
|
|
self.assert_status(response, 200)
|
|
self.assert_has_fields(response.data, "coverage")
|
|
self.assertIsInstance(response.data["coverage"], bool)
|
|
|
|
def test_returns_vet_count(self):
|
|
"""Coverage check should return number of available vets"""
|
|
response = self.get(Endpoints.COVERAGE_CHECK, params={
|
|
"lat": -34.6037,
|
|
"lng": -58.3816,
|
|
})
|
|
|
|
self.assert_status(response, 200)
|
|
self.assert_has_fields(response.data, "vet_count")
|
|
self.assertIsInstance(response.data["vet_count"], int)
|
|
|
|
def test_without_coordinates_fails(self):
|
|
"""Coverage check without coordinates should fail"""
|
|
response = self.get(Endpoints.COVERAGE_CHECK)
|
|
|
|
# Should return 400 or similar error
|
|
self.assertIn(response.status_code, [400, 422])
|