예제 #1
0
    def test_form_valid_data(self):
        """
        Form should be valid.
        """
        form = FraudReportForm(self.data)

        # make sure form is valid
        ok_(form.is_valid())
예제 #2
0
파일: tests.py 프로젝트: Devil399/bedrock
    def test_form_valid_data(self):
        """
        Form should be valid.
        """
        form = FraudReportForm(self.data)

        # make sure form is valid
        ok_(form.is_valid())
예제 #3
0
 def test_form_valid_attachement(self):
     """
     Form should be valid when attachment under/at size limit.
     """
     # attachment within size limit
     mock_attachment = self._create_image_file()
     form = FraudReportForm(self.data, {'input_attachment': mock_attachment})
     # make sure form is valid
     assert form.is_valid()
예제 #4
0
    def test_form_honeypot(self):
        """
        Form with honeypot text box filled should not be valid.
        """
        self.data["office_fax"] = "spammer!"

        form = FraudReportForm(self.data)

        assert not form.is_valid()
예제 #5
0
파일: tests.py 프로젝트: Devil399/bedrock
    def test_form_honeypot(self):
        """
        Form with honeypot text box filled should not be valid.
        """
        self.data['office_fax'] = 'spammer!'

        form = FraudReportForm(self.data)

        eq_(False, form.is_valid())
예제 #6
0
    def test_form_honeypot(self):
        """
        Form with honeypot checkbox checked should not be valid.
        """
        self.data['superpriority'] = True

        form = FraudReportForm(self.data)

        eq_(False, form.is_valid())
예제 #7
0
    def test_form_honeypot(self):
        """
        Form with honeypot text box filled should not be valid.
        """
        self.data['office_fax'] = 'spammer!'

        form = FraudReportForm(self.data)

        eq_(False, form.is_valid())
예제 #8
0
    def test_form_honeypot(self):
        """
        Form with honeypot checkbox checked should not be valid.
        """
        self.data["superpriority"] = True

        form = FraudReportForm(self.data)

        eq_(False, form.is_valid())
예제 #9
0
 def test_form_valid_attachement(self):
     """
     Form should be valid when attachment under/at size limit.
     """
     # attachment within size limit
     mock_attachment = self._create_image_file()
     form = FraudReportForm(self.data,
                            {'input_attachment': mock_attachment})
     # make sure form is valid
     assert form.is_valid()
예제 #10
0
파일: tests.py 프로젝트: Devil399/bedrock
    def test_form_valid_attachement(self):
        """
        Form should be valid when attachment under/at size limit.
        """
        # attachment within size limit
        mock_attachment = Mock(_size=legal_forms.FRAUD_REPORT_FILE_SIZE_LIMIT)

        form = FraudReportForm(self.data, {'input_attachment': mock_attachment})

        # make sure form is valid
        ok_(form.is_valid())
예제 #11
0
    def test_form_valid_attachement(self):
        """
        Form should be valid when attachment under/at size limit.
        """
        # attachment within size limit
        mock_attachment = Mock(_size=legal_forms.FRAUD_REPORT_FILE_SIZE_LIMIT)

        form = FraudReportForm(self.data, {'input_attachment': mock_attachment})

        # make sure form is valid
        ok_(form.is_valid())
예제 #12
0
 def test_form_invalid_attachement_type(self):
     """
     Form should be invalid and contain attachment errors when attachment
     is not an image.
     """
     # attachment within size limit
     mock_attachment = self._create_text_file()
     form = FraudReportForm(self.data, {'input_attachment': mock_attachment})
     # make sure form is not valid
     assert not form.is_valid()
     # make sure attachment errors are in form
     self.assertIn('input_attachment', form.errors)
예제 #13
0
 def test_form_invalid_attachement_type(self):
     """
     Form should be invalid and contain attachment errors when attachment
     is not an image.
     """
     # attachment within size limit
     mock_attachment = self._create_text_file()
     form = FraudReportForm(self.data,
                            {'input_attachment': mock_attachment})
     # make sure form is not valid
     assert not form.is_valid()
     # make sure attachment errors are in form
     self.assertIn('input_attachment', form.errors)
예제 #14
0
파일: tests.py 프로젝트: Devil399/bedrock
    def test_form_invalid_data(self):
        """
        With incorrect data (missing url), form should not be valid and should
        have url in the errors hash.
        """
        self.data.update(input_url='')  # remove required url

        form = FraudReportForm(self.data)

        # make sure form is invalid
        eq_(False, form.is_valid())

        # make sure url errors are in form
        self.assertIn('input_url', form.errors)
예제 #15
0
    def test_form_invalid_data(self):
        """
        With incorrect data (missing url), form should not be valid and should
        have url in the errors hash.
        """
        self.data.update(input_url='')  # remove required url

        form = FraudReportForm(self.data)

        # make sure form is invalid
        eq_(False, form.is_valid())

        # make sure url errors are in form
        self.assertIn('input_url', form.errors)
예제 #16
0
    def test_form_invalid_attachement_size(self):
        """
        Form should be invalid and contain attachment errors when attachment
        over size limit.
        """
        # attachment within size limit
        mock_attachment = self._create_image_file()
        form = FraudReportForm(self.data, {'input_attachment': mock_attachment})
        with patch.object(legal_forms, 'FRAUD_REPORT_FILE_SIZE_LIMIT', 100):
            # make sure form is not valid
            assert not form.is_valid()

        # make sure attachment errors are in form
        self.assertIn('input_attachment', form.errors)
예제 #17
0
    def test_form_invalid_attachement(self):
        """
        Form should be invalid and contain attachment errors when attachment
        over size limit.
        """
        # attachment within size limit
        mock_attachment = Mock(_size=(legal_forms.FRAUD_REPORT_FILE_SIZE_LIMIT + 1))

        form = FraudReportForm(self.data, {"attachment": mock_attachment})

        # make sure form is not valid
        eq_(False, form.is_valid())

        # make sure attachment errors are in form
        self.assertIn("attachment", form.errors)
예제 #18
0
    def test_form_invalid_attachement_size(self):
        """
        Form should be invalid and contain attachment errors when attachment
        over size limit.
        """
        # attachment within size limit
        mock_attachment = self._create_image_file()
        form = FraudReportForm(self.data,
                               {'input_attachment': mock_attachment})
        with patch.object(legal_forms, 'FRAUD_REPORT_FILE_SIZE_LIMIT', 100):
            # make sure form is not valid
            assert not form.is_valid()

        # make sure attachment errors are in form
        self.assertIn('input_attachment', form.errors)
예제 #19
0
    def test_form_invalid_attachement(self):
        """
        Form should be invalid and contain attachment errors when attachment
        over size limit.
        """
        # attachment within size limit
        mock_attachment = Mock(
            _size=(legal_forms.FRAUD_REPORT_FILE_SIZE_LIMIT + 1))

        form = FraudReportForm(self.data, {'input_attachment': mock_attachment})

        # make sure form is not valid
        eq_(False, form.is_valid())

        # make sure attachment errors are in form
        self.assertIn('input_attachment', form.errors)