Exemplo n.º 1
0
 def test_lead_can_access_determination(self):
     submission = ApplicationSubmissionFactory(status='in_discussion', lead=self.user)
     determination = DeterminationFactory(submission=submission, author=self.user, submitted=True)
     response = self.get_page(determination)
     self.assertContains(response, determination.submission.title)
     self.assertContains(response, self.user.full_name)
     self.assertContains(response, submission.get_absolute_url())
Exemplo n.º 2
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'])
Exemplo n.º 3
0
 def test_mixed_determine_notifies(self):
     submission = ApplicationSubmissionFactory()
     dismissed_submission = ApplicationSubmissionFactory(status='rejected')
     DeterminationFactory(submission=dismissed_submission,
                          rejected=True,
                          submitted=True)
     action = 'dismiss'
     response = self.post_page(
         data=self.data(action, [submission, dismissed_submission]))
     self.assertEqual(len(response.context['messages']), 1)
Exemplo n.º 4
0
 def test_can_progress_one_in_mixed_state(self):
     bad_submission = ApplicationSubmissionFactory()
     good_submission = ApplicationSubmissionFactory(
         status='internal_review')
     action = 'close-review'
     self.post_page(
         data=self.data(action, [good_submission, bad_submission]))
     good_submission = self.refresh(good_submission)
     bad_submission = self.refresh(bad_submission)
     self.assertEqual(bad_submission.status, 'in_discussion')
     self.assertEqual(good_submission.status, 'post_review_discussion')
Exemplo n.º 5
0
 def test_can_edit_draft_determination_if_not_lead_with_projects(self):
     submission = ApplicationSubmissionFactory(status='in_discussion')
     determination = DeterminationFactory(submission=submission,
                                          author=self.user,
                                          accepted=True)
     response = self.post_page(submission, {
         'data': 'value',
         'outcome': determination.outcome
     }, 'form')
     self.assertContains(response, 'Approved')
     self.assertRedirects(response,
                          self.absolute_url(submission.get_absolute_url()))
Exemplo n.º 6
0
 def test_cant_resubmit_determination(self):
     submission = ApplicationSubmissionFactory(status='in_discussion',
                                               lead=self.user)
     determination = DeterminationFactory(submission=submission,
                                          author=self.user,
                                          accepted=True,
                                          submitted=True)
     response = self.post_page(submission, {
         'data': 'value',
         'outcome': determination.outcome
     }, 'form')
     self.assertRedirects(response,
                          self.absolute_url(submission.get_absolute_url()))
Exemplo n.º 7
0
 def test_cant_access_without_action(self):
     submission = ApplicationSubmissionFactory()
     url = self.url(None) + '?submissions=' + str(submission.id)
     response = self.client.get(url, follow=True, secure=True)
     self.assertRedirects(response,
                          self.url_from_pattern('apply:submissions:list'))
     self.assertEqual(len(response.context['messages']), 1)
Exemplo n.º 8
0
    def test_second_stage_accepted_determination_creates_project(self):
        submission = ApplicationSubmissionFactory(
            status='proposal_determination',
            workflow_stages=2,
            lead=self.user,
        )

        self.post_page(
            submission, {
                'data': 'value',
                'outcome': ACCEPTED,
                'message': 'You are invited to submit a proposal',
            }, 'form')

        # Cant use refresh from DB with FSM
        submission_original = self.refresh(submission)
        submission_next = submission_original.next
        # import ipdb;ipdb.set_trace()

        # There should be no next submission since rejected is an end to the
        # applications flow.
        self.assertIsNone(submission_next)

        self.assertTrue(hasattr(submission_original, 'project'))
        self.assertFalse(hasattr(submission_next, 'project'))
Exemplo n.º 9
0
    def test_first_stage_rejected_determination_does_not_create_project(self):
        submission = ApplicationSubmissionFactory(
            status='concept_review_discussion',
            workflow_stages=2,
            lead=self.user,
        )

        self.post_page(
            submission, {
                'data': 'value',
                'outcome': REJECTED,
                'message': 'You are not invited to submit a proposal',
            }, 'form')

        # Cant use refresh from DB with FSM
        submission_original = self.refresh(submission)
        submission_next = submission_original.next

        # There should be no next submission since rejected is an end to the
        # applications flow.
        self.assertIsNone(submission_next)

        # Confirm a Project was not created for the original
        # ApplicationSubmission.
        self.assertFalse(hasattr(submission_original, 'project'))
Exemplo n.º 10
0
 def test_review_yes_mixed_opinion(self):
     submission = ApplicationSubmissionFactory()
     review = ReviewFactory(submission=submission)
     ReviewOpinionFactory(review=review, opinion_agree=True)
     ReviewOpinionFactory(review=review, opinion_disagree=True)
     recommendation = submission.reviews.recommendation()
     self.assertEqual(recommendation, MAYBE)
Exemplo n.º 11
0
 def test_review_not_all_opinion(self):
     submission = ApplicationSubmissionFactory()
     ReviewFactory(recommendation_yes=True, submission=submission)
     review = ReviewFactory(recommendation_yes=True, submission=submission)
     ReviewOpinionFactory(review=review, opinion_agree=True)
     recommendation = submission.reviews.recommendation()
     self.assertEqual(recommendation, YES)
Exemplo n.º 12
0
 def test_anonymous_can_not_access(self):
     submission = ApplicationSubmissionFactory()
     response = self.get_page(submission)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(len(response.redirect_chain), 2)
     for path, _ in response.redirect_chain:
         self.assertIn(reverse('users_public:login'), path)
Exemplo n.º 13
0
    def test_reviewers_email(self):
        reviewers = ReviewerFactory.create_batch(4)
        submission = ApplicationSubmissionFactory(status='external_review', reviewers=reviewers, workflow_stages=2)
        self.adapter_process(MESSAGES.READY_FOR_REVIEW, source=submission)

        self.assertEqual(len(mail.outbox), 4)
        self.assertTrue(mail.outbox[0].subject, 'ready to review')
Exemplo n.º 14
0
    def test_staff_cant_remove_reviewers_proposal(self):
        submission = ApplicationSubmissionFactory(reviewers=self.reviewers)
        self.assertCountEqual(submission.reviewers.all(), self.reviewers)

        self.post_form(submission, reviewers=[])

        self.assertCountEqual(submission.reviewers.all(), self.reviewers)
Exemplo n.º 15
0
 def test_gets_blank_if_slack_not_set(self):
     adapter = SlackAdapter()
     submission = ApplicationSubmissionFactory(lead__slack='')
     recipients = adapter.recipients(MESSAGES.COMMENT,
                                     source=submission,
                                     related=None)
     self.assertTrue(submission.lead.slack in recipients[0])
Exemplo n.º 16
0
 def test_no_invite_if_can_edit(self):
     ApplicationSubmissionFactory(user=self.user,
                                  status='concept_more_info',
                                  workflow_stages=2)
     response = self.get_page()
     self.assertNotContains(response, 'Start your ')
     self.assertContains(response, 'Edit', 1)
Exemplo n.º 17
0
    def test_public_transition_kwargs(self):
        submission = ApplicationSubmissionFactory()
        kwargs = self.adapter.extra_kwargs(MESSAGES.TRANSITION,
                                           source=submission,
                                           sources=None)

        self.assertNotIn('visibility', kwargs)
Exemplo n.º 18
0
 def test_no_submissions_waiting_for_review(self):
     submission = ApplicationSubmissionFactory(status='external_review',
                                               workflow_stages=2,
                                               reviewers=[])
     response = self.get_page()
     self.assertNotContains(response, submission.title)
     self.assertEquals(response.context['in_review_count'], 0)
Exemplo n.º 19
0
    def test_message_created_if_determination_exists(self):
        submissions = ApplicationSubmissionFactory.create_batch(2)

        DeterminationFactory(submission=submissions[0], accepted=True, is_draft=False)

        url = self.url(None) + '?submissions=' + ','.join([str(submission.id) for submission in submissions]) + '&action=rejected'
        data = {
            'submissions': [submission.id for submission in submissions],
            'data': 'some data',
            'outcome': REJECTED,
            'message': 'Sorry',
            'author': self.user.id,
        }

        response = self.client.post(url, data, secure=True, follow=True)

        self.assertEqual(submissions[0].determinations.count(), 1)
        self.assertEqual(submissions[0].determinations.first().outcome, ACCEPTED)

        self.assertEqual(submissions[1].determinations.count(), 1)
        self.assertEqual(submissions[1].determinations.first().outcome, REJECTED)

        # 5 base - 2 x django messages, 1 x activity feed, 1 x email, 1 x slack
        # plus 1 extra for unable to determine
        self.assertEqual(len(response.context['messages']), 6)
Exemplo n.º 20
0
 def test_messenger_not_called_with_failed(self, patched):
     submission = ApplicationSubmissionFactory()
     action = 'close-review'
     self.post_page(data=self.data(action, [submission]))
     patched.assert_called_once()
     _, _, kwargs = patched.mock_calls[0]
     self.assertQuerysetEqual(kwargs['sources'],
                              ApplicationSubmission.objects.none())
Exemplo n.º 21
0
    def test_handle_transition_to_public_to_private(self):
        submission = ApplicationSubmissionFactory(status='internal_review')
        old_phase = submission.workflow.phases_for()[0]

        message = self.adapter.handle_transition(old_phase, submission)

        self.assertIn(submission.phase.display_name, message)
        self.assertIn(old_phase.display_name, message)
Exemplo n.º 22
0
    def test_create_from_submission(self):
        submission = ApplicationSubmissionFactory()

        project = Project.create_from_submission(submission)

        self.assertEquals(project.submission, submission)
        self.assertEquals(project.title, submission.title)
        self.assertEquals(project.user, submission.user)
Exemplo n.º 23
0
    def test_internal_transition_kwarg_for_invisible_transition(self):
        submission = ApplicationSubmissionFactory(
            status='post_review_discussion')
        kwargs = self.adapter.extra_kwargs(MESSAGES.TRANSITION,
                                           source=submission,
                                           sources=None)

        self.assertEqual(kwargs['visibility'], TEAM)
Exemplo n.º 24
0
 def test_waiting_for_review_with_count(self):
     submission = ApplicationSubmissionFactory(status='external_review',
                                               workflow_stages=2,
                                               reviewers=[self.user])
     response = self.get_page()
     self.assertContains(response, 'Waiting for your review')
     self.assertContains(response, submission.title)
     self.assertEquals(response.context['awaiting_reviews']['count'], 1)
Exemplo n.º 25
0
 def test_submission_assigned_but_not_in_external_review_status(self):
     submission = ApplicationSubmissionFactory(
         status='concept_review_discussion',
         workflow_stages=2,
         reviewers=[self.user])
     response = self.get_page()
     self.assertNotContains(response, submission.title)
     self.assertEquals(response.context['in_review_count'], 0)
Exemplo n.º 26
0
 def test_cant_edit_submitted_more_info(self):
     submission = ApplicationSubmissionFactory(status='in_discussion',
                                               lead=self.user)
     DeterminationFactory(submission=submission,
                          author=self.user,
                          submitted=True)
     response = self.get_page(submission, 'form')
     self.assertNotContains(response, 'Update ')
Exemplo n.º 27
0
 def test_get_edit_link_when_editable(self):
     submission = ApplicationSubmissionFactory(user=self.user,
                                               status='more_info')
     response = self.get_page(submission)
     self.assertContains(response, 'Edit')
     self.assertContains(response,
                         self.url(submission, 'edit', absolute=False))
     self.assertNotContains(response, 'Congratulations')
Exemplo n.º 28
0
 def test_determine_redirects(self):
     submission = ApplicationSubmissionFactory()
     action = 'dismiss'
     response = self.post_page(data=self.data(action, [submission]))
     redirect_url = self.url_from_pattern(
         'apply:submissions:determinations:batch', absolute=False)
     self.assertEqual(response.request['PATH_INFO'][:len(redirect_url)],
                      redirect_url)
Exemplo n.º 29
0
    def test_no_email_own_comment(self):
        application = ApplicationSubmissionFactory()
        comment = CommentFactory(user=application.user, source=application)

        self.adapter_process(MESSAGES.COMMENT,
                             related=comment,
                             user=comment.user,
                             source=comment.source)
        self.assertEqual(len(mail.outbox), 0)
Exemplo n.º 30
0
 def test_handles_negative_reviews(self):
     submission = ApplicationSubmissionFactory()
     ReviewFactory(submission=submission)
     data = ReviewSummarySerializer(submission).data
     self.assertEqual(data['count'], 1)
     self.assertEqual(data['score'], 0)
     self.assertEqual(data['recommendation'], {'value': 0, 'display': 'No'})
     self.assertEqual(len(data['assigned']), 1)
     self.assertEqual(len(data['reviews']), 1)