Skip to content

Commit

Permalink
refactor(test): less dependence on database contents
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Nov 1, 2023
1 parent 53a2eb6 commit 70ea25d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions tests/pytest/core/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,18 @@ def test_TransitAgency_by_slug_nonmatching():

@pytest.mark.django_db
def test_TransitAgency_all_active(model_TransitAgency):
assert TransitAgency.objects.count() == 1
count = TransitAgency.objects.count()
assert count >= 1

inactive_agency = TransitAgency.by_id(model_TransitAgency.id)
inactive_agency.pk = None
inactive_agency.active = False
inactive_agency.save()

assert TransitAgency.objects.count() == 2
assert TransitAgency.objects.count() == count + 1

result = TransitAgency.all_active()

assert len(result) == 1
assert len(result) > 0
assert model_TransitAgency in result
assert inactive_agency not in result
2 changes: 1 addition & 1 deletion tests/pytest/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -eu

# run normal pytests
coverage run -m pytest --no-migrations
coverage run -m pytest

# clean out old coverage results
rm -rf benefits/static/coverage
Expand Down

0 comments on commit 70ea25d

Please sign in to comment.