def test_get_by_id_unknown_fails(self, mocked_repo): # Given mocked_repo.return_value = [] requested_id = 'unknown_id' repo = GeographyRepository() # Then with pytest.raises(CatalogError): repo.get_by_id(requested_id)
def test_get_by_slug(self, mocked_repo): # Given mocked_repo.return_value = [db_geography1] requested_slug = db_geography1['slug'] repo = GeographyRepository() # When geography = repo.get_by_id(requested_slug) # Then mocked_repo.assert_called_once_with({'slug': [requested_slug]}) assert geography == test_geography1
def test_get_by_id(self, mocked_repo): # Given mocked_repo.return_value = [db_geography1] requested_id = db_geography1['id'] repo = GeographyRepository() # When geography = repo.get_by_id(requested_id) # Then mocked_repo.assert_called_once_with({'id': [requested_id]}) assert isinstance(geography, Geography) assert geography == test_geography1