americanhandelsociety / americanhandelsociety-members

0 stars 0 forks source link

Fix flaky test #117

Closed reginafcompton closed 2 years ago

reginafcompton commented 2 years ago

"test_filter_matches_admin_updated_past_month" occasionally fails like so:

========================================== FAILURES ==========================================
________________________ test_filter_matches_admin_updated_past_month ________________________

artificially_backdated_pre_004_migration_members = [<Member: dfliptmn@email.com>, <Member: nhpbqmkc@email.com>, <Member: ucobyhiw@email.com>]
member = <Member: rodelinda@lombardy.sa>
address = <Address: The Handel House Trust Ltd, 25 Brook Street, London, W1K 4HB, UK>

    @pytest.mark.django_db
    def test_filter_matches_admin_updated_past_month(
        artificially_backdated_pre_004_migration_members, member, address
    ):
        qs = Member.objects.all()
        random_member = choice(qs)
        random_member.address = address
        random_member.save()
        admin = Admin(Member, AdminSite)
        expected_in_qs_filter = [x for x in qs if admin.updated_past_month(x)]
>       assert len(expected_in_qs_filter) == 2
E       assert 1 == 2
E        +  where 1 = len([<Member: rodelinda@lombardy.sa>]
reginafcompton commented 2 years ago

cc: @ecedmondson - very low priority. (I can take a look eventually, but I thought you might be interested!)

ecedmondson commented 2 years ago

sure

ecedmondson commented 2 years ago

So, on first thought, this test might not actually even be needed anymore. I'll have to revisit. I put it in out of an abudance of caution for the "profile update within the last 30 days" admin feature...iirc correctly it has been more than 30 days since that feature was merged. Any new accounts will be created with the model after the migration, meaning that this was really a test for members who joined prior to the migration but before the first 30 days had elapsed. What do you think? @reginafcompton

reginafcompton commented 2 years ago

Ah, good point! Then, yes, let's just do away with these tests entirely.

ecedmondson commented 2 years ago

Sure, sounds good.

ecedmondson commented 2 years ago

I was wrong. I do think I have a fix for this. My bad for the back and forth.