Skip to content

Commit

Permalink
Update pytest and fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ronardcaktus committed Jun 20, 2024
1 parent c5eee7b commit 31bb71f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion nc/tests/api/test_arrests.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_sort_by_stop_purpose(self):
self.assertEqual(sort_by_stop_purpose(df)["stop_purpose"].tolist(), StopPurpose.values)


@pytest.mark.django_db
@pytest.mark.django_db(databases=["traffic_stops_nc"])
class TestArrests:
def test_arrest_contraband_missing_race(self, client, durham):
"""A single stop will result no data for other races"""
Expand Down
3 changes: 3 additions & 0 deletions nc/tests/api/test_basic_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ def test_no_agency(client, search_url):
assert response.status_code == status.HTTP_400_BAD_REQUEST


@pytest.mark.django_db(databases=["traffic_stops_nc"])
def test_agency_success(client, search_url, durham):
response = client.get(search_url, data={"agency": durham.pk}, format="json")
assert response.status_code == status.HTTP_200_OK


@pytest.mark.django_db(databases=["traffic_stops_nc"])
def test_response_person_fields(client, search_url, durham):
person = factories.PersonFactory(stop__agency=durham)
response = client.get(search_url, data={"agency": durham.pk}, format="json")
Expand All @@ -42,6 +44,7 @@ def test_response_person_fields(client, search_url, durham):
assert result == expected


@pytest.mark.django_db(databases=["traffic_stops_nc"])
@pytest.mark.parametrize("race", RACE_VALUES)
def test_race_filtering(client, search_url, durham, race):
other_races = RACE_VALUES - set(race)
Expand Down
3 changes: 3 additions & 0 deletions nc/tests/api/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def august_person(durham):
return factories.PersonFactory(stop__agency=durham, stop__date=stop_date)


@pytest.mark.django_db(databases=["traffic_stops_nc"])
def test_stop_date_after_august_excludes_july_stop(client, search_url, durham, july_person):
response = client.get(
search_url,
Expand All @@ -33,6 +34,7 @@ def test_stop_date_after_august_excludes_july_stop(client, search_url, durham, j
assert july_person.stop.stop_id not in stop_ids


@pytest.mark.django_db(databases=["traffic_stops_nc"])
def test_stop_date_after_august_includes_august_stop(client, search_url, durham, august_person):
response = client.get(
search_url,
Expand All @@ -44,6 +46,7 @@ def test_stop_date_after_august_includes_august_stop(client, search_url, durham,
assert august_person.stop.date == response.data["results"][0]["date"]


@pytest.mark.django_db(databases=["traffic_stops_nc"])
def test_stop_date_after_july_includes_both(client, search_url, durham, july_person, august_person):
response = client.get(
search_url,
Expand Down
5 changes: 1 addition & 4 deletions requirements/dev/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ asgiref==3.5.2
# django
attrs==19.3.0
# via
# -c requirements/dev/../test/test.txt
# jsonschema
# referencing
awscli==1.32.100
Expand Down Expand Up @@ -281,9 +280,7 @@ urwid==2.1.0
watchdog==0.10.3
# via sphinx-autobuild
wcwidth==0.1.9
# via
# -c requirements/dev/../test/test.txt
# prompt-toolkit
# via prompt-toolkit
websocket-client==0.57.0
# via kubernetes
wheel==0.37.1
Expand Down
6 changes: 3 additions & 3 deletions requirements/test/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

pyyaml
isort
pytest
pytest-cov
pytest==8.2.2
pytest-cov==5.0.0
factory_boy
pytest-django
pytest-django==4.8.0
coverage
# Linting
flake8
Expand Down
27 changes: 13 additions & 14 deletions requirements/test/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
# pip-compile --output-file=requirements/test/test.txt requirements/test/test.in
#
attrs==19.3.0
# via pytest
black==24.4.2
# via -r requirements/test/test.in
cfgv==3.1.0
Expand All @@ -14,12 +12,14 @@ click==8.1.7
# via
# -c requirements/test/../base/base.txt
# black
coverage==5.1
coverage[toml]==7.5.3
# via
# -r requirements/test/test.in
# pytest-cov
distlib==0.3.6
# via virtualenv
exceptiongroup==1.2.1
# via pytest
factory-boy==2.12.0
# via -r requirements/test/test.in
faker==4.1.0
Expand All @@ -32,12 +32,12 @@ identify==2.5.36
# via
# -r requirements/test/test.in
# pre-commit
iniconfig==2.0.0
# via pytest
isort==4.3.21
# via -r requirements/test/test.in
mccabe==0.6.1
# via flake8
more-itertools==8.2.0
# via pytest
mypy-extensions==0.4.3
# via black
nodeenv==1.3.5
Expand All @@ -52,24 +52,22 @@ platformdirs==2.4.0
# via
# black
# virtualenv
pluggy==0.13.1
pluggy==1.5.0
# via pytest
pre-commit==3.5.0
# via -r requirements/test/test.in
py==1.8.1
# via pytest
pycodestyle==2.6.0
# via flake8
pyflakes==2.2.0
# via flake8
pytest==5.4.2
pytest==8.2.2
# via
# -r requirements/test/test.in
# pytest-cov
# pytest-django
pytest-cov==2.8.1
pytest-cov==5.0.0
# via -r requirements/test/test.in
pytest-django==3.9.0
pytest-django==4.8.0
# via -r requirements/test/test.in
python-dateutil==2.8.1
# via
Expand All @@ -86,10 +84,11 @@ six==1.15.0
text-unidecode==1.3
# via faker
tomli==2.0.1
# via black
# via
# black
# coverage
# pytest
typing-extensions==4.12.2
# via black
virtualenv==20.17.1
# via pre-commit
wcwidth==0.1.9
# via pytest

0 comments on commit 31bb71f

Please sign in to comment.