Esempio n. 1
0
    def test_contact_valid_form(self):
        db = self.application.db()
        get_response = default.contact()

        self.request.function = 'edit'
        self.request._post_vars = Storage({
            'first_name':
            'Test',
            'last_name':
            'User',
            'email':
            '*****@*****.**',
            '_formkey':
            get_response['form'].formkey,
            '_formname':
            get_response['form'].formname
        })

        try:
            default.contact()
            db.commit()
        except HTTP:
            pass
        except Exception:
            self.fail('Unexpected exception thrown')
        else:
            self.fail('No exception thrown')

        # check to see if we have a single record
        self.assertEqual(db(db.Contact.id != 0).count(), 1)
    def test_contact_valid_form(self):
        db = self.application.db()
        get_response = default.contact()

        self.request.function = 'edit'
        self.request._post_vars = Storage({
            'first_name': 'Test',
            'last_name': 'User',
            'email': '*****@*****.**',
            '_formkey': get_response['form'].formkey,
            '_formname': get_response['form'].formname
        })

        try:
            default.contact()
            db.commit()
        except HTTP:
            pass
        except Exception:
            self.fail('Unexpected exception thrown')
        else:
            self.fail('No exception thrown')

        # check to see if we have a single record
        self.assertEqual(db(db.Contact.id != 0).count(), 1)
    def test_contact_empty_form(self):
        get_response = default.contact()

        self.request._post_vars = Storage({
            '_formkey': get_response['form'].formkey,
            '_formname': get_response['form'].formname
        })

        post_response = default.contact()
        errors = post_response['form'].errors
        self.assertEqual(errors.first_name, 'Please enter a first name')
        self.assertEqual(errors.last_name, 'Please enter a last name')
        self.assertEqual(errors.email, 'Enter a valid email')
Esempio n. 4
0
    def test_contact_empty_form(self):
        get_response = default.contact()

        self.request._post_vars = Storage({
            '_formkey':
            get_response['form'].formkey,
            '_formname':
            get_response['form'].formname
        })

        post_response = default.contact()
        errors = post_response['form'].errors
        self.assertEqual(errors.first_name, 'Please enter a first name')
        self.assertEqual(errors.last_name, 'Please enter a last name')
        self.assertEqual(errors.email, 'Enter a valid email')