예제 #1
0
    def test_get_in_correct_order(self):
        submission = ApplicationSubmissionFactory()

        revision = ApplicationRevisionFactory(submission=submission)
        ApplicationRevision.objects.filter(id=revision.id).update(timestamp=datetime.now() - timedelta(days=1))

        revision_older = ApplicationRevisionFactory(submission=submission)
        ApplicationRevision.objects.filter(id=revision_older.id).update(timestamp=datetime.now() - timedelta(days=2))

        response = self.get_page(submission)

        self.assertSequenceEqual(
            response.context['object_list'],
            [submission.live_revision, revision, revision_older],
        )
예제 #2
0
    def test_gets_draft_on_edit_submission(self):
        draft_revision = ApplicationRevisionFactory(submission=self.draft_proposal_submission)
        self.draft_proposal_submission.draft_revision = draft_revision
        self.draft_proposal_submission.save()

        response = self.get_page(self.draft_proposal_submission, 'edit')
        self.assertDictEqual(response.context['object'].form_data, draft_revision.form_data)
예제 #3
0
 def test_can_have_draft_titles_on_dashboard(self):
     submission = ApplicationSubmissionFactory(user=self.user)
     draft_revision = ApplicationRevisionFactory(submission=submission)
     submission.draft_revision = draft_revision
     submission.save()
     response = self.get_page()
     self.assertNotContains(response, submission.title)
     self.assertContains(response, submission.from_draft().title)
     self.assertNotContains(response, 'Submission history')
예제 #4
0
    def test_list_doesnt_include_draft(self):
        submission = ApplicationSubmissionFactory()
        draft_revision = ApplicationRevisionFactory(submission=submission)
        submission.draft_revision = draft_revision
        submission.save()

        response = self.get_page(submission)

        self.assertNotIn(draft_revision, response.context['object_list'])
예제 #5
0
    def test_sees_latest_draft_if_it_exists(self):
        draft_revision = ApplicationRevisionFactory(submission=self.submission)
        self.submission.draft_revision = draft_revision
        self.submission.save()

        draft_submission = self.submission.from_draft()
        response = self.get_page(self.submission)

        self.assertContains(response, draft_submission.title)