示例#1
0
 def test_should_not_validate_if_message_data_is_equal_default(self):
     with app.app_context():
         form = CertificateForm(participants='john,[email protected]')
         self.assertFalse(form.validate(),
                          'A malformed form was validated successfully')
         self.assertEqual(
             form.errors['message'][0],
             'You need provide a custom text to your form message')
示例#2
0
 def test_should_not_validate_for_msg_with_no_participant_placeholder(self):
     with app.app_context():
         form = CertificateForm(message='message without placeholder',
                                participants='john,[email protected]')
         self.assertFalse(form.validate(),
                          'A malformed form was validated successfully')
         self.assertEqual(form.errors['message'][0],
                          'Your message need a [participante] placeholder')
示例#3
0
 def test_should_not_validate_if_participants_dont_have_a_valid_csv(self):
     with app.app_context():
         form = CertificateForm(
             message='message with [participante] placeholder',
             participants='wrong-format')
         self.assertFalse(form.validate(),
                          'A malformed form was validated successfully')
         self.assertEqual(form.errors['participants'][0],
                          'You provide a wrong formated participants list')
示例#4
0
 def test_should_valid_form_have_a_participants_list_with_parsed_data(self):
     with app.app_context():
         form = CertificateForm(
             message='message with [participante] placeholder',
             participants='john,[email protected]')
         form.validate()
         self.assertTrue(form.participants_list)
         self.assertEqual(form.participants_list, [{
             'name': 'john',
             'email': '*****@*****.**'
         }])
示例#5
0
 def test_should_save_on_mongodb_if_data_is_correct(self, enqueue_mock):
     self.client.post('/send-certificates',
                      data={
                          'logo': '123',
                          'message': 'abc [participante] def',
                          'participants': 'rael,[email protected]'
                      })
     with app.app_context():
         certificate = mongo.db.certificates.find_one()
         self.assertTrue(certificate)
         self.assertEqual(certificate['logo'], '123')
         self.assertEqual(certificate['message'], 'abc [participante] def')
         self.assertEqual(certificate['participants'],
                          [{
                              'name': 'rael',
                              'email': '*****@*****.**'
                          }])
示例#6
0
 def test_should_not_validate_empty_form(self):
     with app.app_context():
         form = CertificateForm()
         self.assertFalse(
             form.validate(),
             'A empty CertificateForm was validated successfully')
示例#7
0
 def test_should_have_a_textarea_to_participants(self):
     with app.app_context():
         form = CertificateForm()
         self.assertEqual(form.participants.type, 'TextAreaField')
示例#8
0
 def test_should_have_a_textarea_to_message(self):
     with app.app_context():
         form = CertificateForm()
         self.assertEqual(form.message.type, 'TextAreaField')
示例#9
0
 def test_should_have_a_hiddenfield_to_logo_value(self):
     with app.app_context():
         form = CertificateForm()
         self.assertEqual(form.logo.type, 'HiddenField')
示例#10
0
 def test_should_have_a_filefield_to_logo(self):
     with app.app_context():
         form = CertificateForm()
         self.assertEqual(form.logo_file.type, 'FileField')
示例#11
0
 def tearDown(self):
     with app.app_context():
         mongo.db.command('dropDatabase')