Example #1
0
 def test_form_when_round(self):
     rfp = RequestForPartnersFactory()
     TodayRoundFactory(parent=rfp)
     request = make_request(site=rfp.get_site())
     response = rfp.serve(request)
     self.assertNotContains(response, 'not accepting')
     self.assertContains(response, 'Submit')
Example #2
0
    def submit_form(self, page=None, email=None, name=None, user=AnonymousUser(), ignore_errors=False):
        page = page or self.round_page

        fields = page.forms.first().fields
        data = CustomFormFieldsFactory.form_response(fields)

        # Add our own data
        for field in page.forms.first().fields:
            if isinstance(field.block, EmailBlock):
                data[field.id] = self.email if email is None else email
            if isinstance(field.block, FullNameBlock):
                data[field.id] = self.name if name is None else name

        request = make_request(user, data, method='post', site=self.site)

        if page.get_parent().id != self.site.root_page.id:
            # Its a fund
            response = page.get_parent().serve(request)
        else:
            response = page.serve(request)

        if not ignore_errors:
            # Check the data we submit is correct
            self.assertNotContains(response, 'errors')
        return response
Example #3
0
    def test_django_messages_used(self):
        request = make_request()

        self.adapter_process(MESSAGES.UPDATE_LEAD, request=request)

        messages = list(get_messages(request))
        self.assertEqual(len(messages), 1)
        self.assertTrue(MESSAGES.UPDATE_LEAD.value in messages[0].message)
        self.assertTrue(self.adapter.adapter_type in messages[0].message)
Example #4
0
    def process_kwargs(self, message_type, **kwargs):
        if 'user' not in kwargs:
            kwargs['user'] = UserFactory()
        if 'submission' not in kwargs:
            kwargs['submission'] = ApplicationSubmissionFactory()
        if 'request' not in kwargs:
            kwargs['request'] = make_request()
        if message_type in neat_related:
            kwargs['related'] = kwargs.get('related', 'a thing')
        else:
            kwargs['related'] = None

        return kwargs
Example #5
0
    def process_kwargs(self, message_type, **kwargs):
        if 'user' not in kwargs:
            kwargs['user'] = UserFactory()
        if 'source' not in kwargs:
            kwargs['source'] = self.source_factory()
        if 'request' not in kwargs:
            kwargs['request'] = make_request()
        if message_type in neat_related:
            kwargs['related'] = kwargs.get('related', 'a thing')
        else:
            kwargs['related'] = None

        return kwargs
Example #6
0
    def test_new_form_after_progress(self):
        submission = ApplicationSubmissionFactory(status='invited_to_proposal', workflow_stages=2, lead=self.user)
        stage = submission.stage
        DeterminationFactory(submission=submission, accepted=True)

        request = make_request(self.user, method='get', site=submission.page.get_site())
        submission.progress_stage_when_possible(self.user, request)

        submission = self.refresh(submission)
        new_stage = submission.stage

        self.assertNotEqual(stage, new_stage)

        get_forms = submission.get_from_parent('get_defined_fields')
        self.assertEqual(submission.form_fields, get_forms(new_stage))
        self.assertNotEqual(submission.form_fields, get_forms(stage))
Example #7
0
 def test_message_when_no_round(self):
     rfp = RequestForPartnersFactory()
     request = make_request(site=rfp.get_site())
     response = rfp.serve(request)
     self.assertContains(response, 'not accepting')
     self.assertNotContains(response, 'Submit')