Exemple #1
0
 def test_400_invalid(self):
     response = self.__send_request(fake.sentence())
     self._assert_400(response, {
         "token": [
             "Invalid token.",
         ],
     })
Exemple #2
0
 def test_ContactSchema_trims_subject(self):
     subject = fake.sentence()
     body = get_mock_contact_body(subject=f"  {subject}  ")
     errors = contact_schema.validate(body)
     assert not errors
     dumped = contact_schema.dump(body)
     assert dumped["subject"] == subject
Exemple #3
0
 def test_ContactSchema_trims_message(self):
     message = fake.sentence()
     body = get_mock_contact_body(message=f"  {message}  ")
     errors = contact_schema.validate(body)
     assert not errors
     dumped = contact_schema.dump(body)
     assert dumped["message"] == message
Exemple #4
0
 def test_send_contact_emails(self, sengrid):
     receiver = fake.email()
     self._app.config.update({"CONTACT_EMAIL": receiver})
     sender = fake.email()
     subject = fake.sentence()
     message = fake.sentence()
     send_contact_emails(sender, subject, message)
     data = {
         "email": sender,
         "subject": subject,
         "message": message,
     }
     sengrid.send.assert_has_calls([
         call(TemplateIds.CONTACT_RECEIVER, receiver, data),
         call(TemplateIds.CONTACT_SENDER, sender, data),
     ],
                                   any_order=True)
Exemple #5
0
 def test_SignUpSchema_invalid_email(self):
     email = fake.sentence()
     body = get_mock_sign_up_body(email=email)
     errors = sign_up_schema.validate(body)
     assert errors == {
         "email": [
             "Not a valid email address.",
         ],
     }
Exemple #6
0
 def test_EmailPasswordSchema_invalid_email(self):
     email = fake.sentence()
     body = get_mock_email_password_body(email=email)
     errors = email_password_schema.validate(body)
     assert errors == {
         "email": [
             "Not a valid email address.",
         ],
     }
Exemple #7
0
 def test_ContactSchema_invalid_email(self):
     email = fake.sentence()
     body = get_mock_contact_body(email=email)
     errors = contact_schema.validate(body)
     assert errors == {
         "email": [
             "Not a valid email address.",
         ],
     }
Exemple #8
0
def get_mock_contact_body(**kwargs):
    return {
        "email": kwargs.get("email", fake.email()),
        "subject": kwargs.get("subject", fake.sentence()),
        "message": kwargs.get("message", fake.sentence()),
    }