@@ -0,0 +1,2600 @@
+from datetime import timedelta%0Aimport re%0A%0Aimport pytest%0Afrom django.utils.timezone import now%0Afrom django.core.management import call_command%0A%0Afrom proposals.models import TalkProposal%0A%0A%0A@pytest.fixture()%0Adef weekago_talk_proposal(user):%0A    dt_weekago = now() - timedelta(weeks=1)%0A    proposal = TalkProposal.objects.create(%0A        id=56,%0A        submitter=user,%0A        title='Long long time ago when Python was still 2.x',%0A    )%0A    proposal.created_at = dt_weekago%0A    proposal.save()%0A    return proposal%0A%0A%0Adef test_weekago_talk_created_datetime(weekago_talk_proposal):%0A    proposal_lifetime = now() - weekago_talk_proposal.created_at%0A    print('The proposal has been created for %25d days' %25 proposal_lifetime.days)%0A    assert proposal_lifetime %3E= timedelta(weeks=1)%0A%0A%0A@pytest.fixture()%0Adef another_user_dayago_talk_proposal(another_user):%0A    dt_dayago = now() - timedelta(days=1)%0A    proposal = TalkProposal.objects.create(%0A        id=9527,%0A        submitter=another_user,%0A        title='Transition from Ruby to Python',%0A        created_at=dt_dayago,%0A    )%0A    return proposal%0A%0A%0Adef test_recent_proposal_command_default(%0A    talk_proposal, weekago_talk_proposal,%0A    another_user_dayago_talk_proposal,%0A    capsys,%0A):%0A    call_command('recent_proposals')%0A    out, err = capsys.readouterr()%0A    print(out)%0A%0A    # Test only two talk proposals are retrieved%0A    assert re.search(r%22Got total 2 new proposals%22, out, re.MULTILINE)%0A    # Test the title of these two proposals are in the output%0A    for proposal in %5Btalk_proposal, another_user_dayago_talk_proposal%5D:%0A        assert re.search(proposal.title, out, re.MULTILINE)%0A%0A    # Test the title of outdated proposals are not in the output%0A    assert not re.search(weekago_talk_proposal.title, out, re.MULTILINE)%0A%0A%0Adef test_cancelled_proposal_not_shown_in_recent_proposals(%0A    cancelled_talk_proposal,%0A    another_user_dayago_talk_proposal,%0A    weekago_talk_proposal,%0A    capsys,%0A):%0A    call_command('recent_proposals', recent=6)%0A    out, err = capsys.readouterr()%0A    print(out)%0A%0A    # Test only one talk proposal is retrieved%0A    assert re.search(r%22Got total 1 new proposals%22, out, re.MULTILINE)%0A    assert re.search(another_user_dayago_talk_proposal.title, out, re.MULTILINE)%0A    for proposal in %5Bcancelled_talk_proposal, weekago_talk_proposal%5D:%0A        assert not re.search(%0A            proposal.title, out, re.MULTILINE%0A        )%0A%0A%0A@pytest.mark.django_db%0Adef test_no_recent_proposal(capsys):%0A    call_command('recent_proposals')%0A    out, err = capsys.readouterr()%0A    print(err)%0A    assert re.search('No proposals are recently submitted', err)%0A

Add unittest for command recent_proposals