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 e2ba212 commit fd2aaef
Showing 1 changed file with 5 additions and 3 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

0 comments on commit fd2aaef

Please sign in to comment.