Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hancush committed Jul 17, 2024
1 parent 875ae76 commit 73663b5
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions pupa/tests/clean/test_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,6 @@ def test_get_stale_objects(subparsers, organization, person):
assert set(Command(subparsers).get_stale_objects(7)) == expected_stale_objects


@pytest.mark.django_db
def test_remove_stale_objects(subparsers, organization, person):
stale_person = person.build()
membership = stale_person.memberships.create(organization=organization)

expected_stale_objects = {stale_person, organization, membership}

a_week_from_now = datetime.now(tz=timezone.utc) + timedelta(days=7)
with freeze_time(a_week_from_now):
fresh_person = person.build(name="Thomas Jefferson", family_name="Jefferson")
fresh_person.memberships.create(organization=organization)

Command(subparsers).remove_stale_objects(7)
for obj in expected_stale_objects:
was_deleted = not type(obj).objects.filter(id=obj.id).exists()
assert was_deleted


@pytest.mark.django_db
def test_clean_command(subparsers, organization, person):
stale_person = person.build()
Expand All @@ -106,8 +88,8 @@ def test_clean_command(subparsers, organization, person):
was_deleted = not type(obj).objects.filter(id=obj.id).exists()
assert was_deleted

expected_not_stale_objects = {organization, fresh_person, not_stale_membership}
for obj in expected_not_stale_objects:
expected_fresh_objects = {organization, fresh_person, not_stale_membership}
for obj in expected_fresh_objects:
was_not_deleted = type(obj).objects.filter(id=obj.id).exists()
assert was_not_deleted

Expand Down

0 comments on commit 73663b5

Please sign in to comment.