Skip to content

Commit

Permalink
Add tests for unit endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
japauliina committed Dec 19, 2023
1 parent f0835e4 commit a275bf0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions services/tests/test_unit_view_set_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def create_units():
description_fi="Kuvaus suomeksi",
description_sv="Beskrivning på svenska",
description_en="Description in English",
provider_type=2,
)
# Unit with private service
Unit.objects.create(
Expand Down Expand Up @@ -395,3 +396,30 @@ def test_translations(api_client):
assert unit_with_translations["description"]["fi"] == "Kuvaus suomeksi"
assert unit_with_translations["description"]["sv"] == "Beskrivning på svenska"
assert unit_with_translations["description"]["en"] == "Description in English"


@pytest.mark.django_db
def test_id_filter(api_client):
create_units()
response = get(api_client, reverse("unit-list"), data={"id": "2,3"})
assert response.status_code == 200
assert response.data["count"] == 2
assert response.data["results"][0]["id"] == 3
assert response.data["results"][1]["id"] == 2


@pytest.mark.django_db
def tests_provider_type_filter(api_client):
create_units()
response = get(api_client, reverse("unit-list"), data={"provider_type": 2})
assert response.status_code == 200
assert response.data["count"] == 1
assert response.data["results"][0]["id"] == 1


@pytest.mark.django_db
def test_provider_type_not_filter(api_client):
create_units()
response = get(api_client, reverse("unit-list"), data={"provider_type__not": 2})
assert response.status_code == 200
assert response.data["count"] == 4

0 comments on commit a275bf0

Please sign in to comment.