diff --git a/parkings/tests/api/enforcement/test_operator.py b/parkings/tests/api/enforcement/test_operator.py index 7fa11bf9..e21a1ba3 100644 --- a/parkings/tests/api/enforcement/test_operator.py +++ b/parkings/tests/api/enforcement/test_operator.py @@ -14,7 +14,8 @@ def get_url(kind, operator): if kind == 'list': return list_url - elif kind == 'detail': + else: + assert kind == 'detail' return reverse('enforcement:v1:operator-detail', kwargs={'pk': operator.pk}) diff --git a/parkings/tests/api/enforcement/test_valid_parking.py b/parkings/tests/api/enforcement/test_valid_parking.py index 28658792..8164c36a 100644 --- a/parkings/tests/api/enforcement/test_valid_parking.py +++ b/parkings/tests/api/enforcement/test_valid_parking.py @@ -25,7 +25,8 @@ def get_url(kind, parking): return list_url elif kind == 'list_by_reg_num': return list_url_for(parking.registration_number) - elif kind == 'detail': + else: + assert kind == 'detail' return reverse('enforcement:v1:valid_parking-detail', kwargs={'pk': parking.pk}) diff --git a/parkings/tests/api/operator/test_parking.py b/parkings/tests/api/operator/test_parking.py index 5e0fbb67..8f7505ac 100644 --- a/parkings/tests/api/operator/test_parking.py +++ b/parkings/tests/api/operator/test_parking.py @@ -41,13 +41,6 @@ def updated_parking_data(): } -def check_parking_data_keys(parking_data): - assert set(parking_data.keys()) == { - 'id', 'created_at', 'modified_at', 'location', 'registration_number', 'time_start', 'time_end', 'zone', - 'status', - } - - def check_parking_data_matches_parking_object(parking_data, parking_obj): """ Check that a parking data dict and an actual Parking object match. diff --git a/parkings/tests/api/public/test_parking_area_statistics.py b/parkings/tests/api/public/test_parking_area_statistics.py index ecc19c78..99f35978 100644 --- a/parkings/tests/api/public/test_parking_area_statistics.py +++ b/parkings/tests/api/public/test_parking_area_statistics.py @@ -45,10 +45,13 @@ def test_get_list_check_data(api_client, parking_factory, parking_area_factory, results = get(api_client, list_url)['results'] assert len(results) == 4 - stats_data_1 = next(result for result in results if result['id'] == str(parking_area_1.id)) - stats_data_2 = next(result for result in results if result['id'] == str(parking_area_2.id)) - stats_data_3 = next(result for result in results if result['id'] == str(parking_area_3.id)) - stats_data_4 = next(result for result in results if result['id'] == str(parking_area_4.id)) + def find_by_obj_id(obj, iterable): + return [x for x in iterable if x['id'] == str(obj.id)][0] + + stats_data_1 = find_by_obj_id(parking_area_1, results) + stats_data_2 = find_by_obj_id(parking_area_2, results) + stats_data_3 = find_by_obj_id(parking_area_3, results) + stats_data_4 = find_by_obj_id(parking_area_4, results) assert stats_data_1.keys() == {'id', 'current_parking_count'} assert stats_data_1['current_parking_count'] == 4 diff --git a/parkings/tests/api/utils.py b/parkings/tests/api/utils.py index 01f7dcb4..23c2c63b 100644 --- a/parkings/tests/api/utils.py +++ b/parkings/tests/api/utils.py @@ -72,7 +72,7 @@ def check_required_fields(api_client, url, expected_required_fields, detail_endp required_fields = set() for (field, errors) in response_data.items(): - if 'This field is required.' in repr(errors): + if 'This field is required.' in repr(errors): # pragma: no cover required_fields.add(field) assert required_fields == expected_required_fields, '%s != %s' % (required_fields, expected_required_fields)