예제 #1
0
 def test_SignUpSchema_trims_email(self):
     email = fake.email()
     body = get_mock_sign_up_body(email=f"  {email}  ")
     errors = sign_up_schema.validate(body)
     assert not errors
     dumped = sign_up_schema.dump(body)
     assert dumped["email"] == email
예제 #2
0
 def test_SignUpSchema_trims_name(self):
     name = fake.name()
     body = get_mock_sign_up_body(name=f"  {name}  ")
     errors = sign_up_schema.validate(body)
     assert not errors
     dumped = sign_up_schema.dump(body)
     assert dumped["name"] == name
예제 #3
0
 def test_SignUpSchema_blank_email(self):
     body = get_mock_sign_up_body(email=" ")
     errors = sign_up_schema.validate(body)
     assert errors == {
         "email": [
             "Missing data for required field.",
         ],
     }
예제 #4
0
 def test_SignUpSchema_name_equal_to_max(self):
     name = fake.pystr(
         min_chars=Limits.MAX_USER_NAME_LENGTH,
         max_chars=Limits.MAX_USER_NAME_LENGTH,
     )
     body = get_mock_sign_up_body(name=name)
     errors = sign_up_schema.validate(body)
     assert not errors
예제 #5
0
 def test_SignUpSchema_password_equal_to_max(self):
     password = fake.pystr(
         min_chars=Limits.MAX_USER_PASSWORD_LENGTH,
         max_chars=Limits.MAX_USER_PASSWORD_LENGTH,
     )
     body = get_mock_sign_up_body(password=password)
     errors = sign_up_schema.validate(body)
     assert not errors
예제 #6
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.",
         ],
     }
예제 #7
0
 def test_SignUpSchema_no_name(self):
     body = get_mock_sign_up_body()
     del body["name"]
     errors = sign_up_schema.validate(body)
     assert errors == {
         "name": [
             "Missing data for required field.",
         ],
     }
예제 #8
0
 def test_SignUpSchema_name_greater_than_max(self):
     name = fake.pystr(
         min_chars=Limits.MAX_USER_NAME_LENGTH + 1,
         max_chars=Limits.MAX_USER_NAME_LENGTH + 1,
     )
     body = get_mock_sign_up_body(name=name)
     errors = sign_up_schema.validate(body)
     assert errors == {
         "name": [
             f"Longer than maximum length {Limits.MAX_USER_NAME_LENGTH}.",
         ],
     }
예제 #9
0
 def test_SignUpSchema_password_greater_than_max(self):
     password = fake.pystr(
         min_chars=Limits.MAX_USER_PASSWORD_LENGTH + 1,
         max_chars=Limits.MAX_USER_PASSWORD_LENGTH + 1,
     )
     body = get_mock_sign_up_body(password=password)
     errors = sign_up_schema.validate(body)
     assert errors == {
         "password": [
             f"Length must be between {Limits.MIN_USER_PASSWORD_LENGTH} "
             f"and {Limits.MAX_USER_PASSWORD_LENGTH}.",
         ],
     }
예제 #10
0
 def test_SignUpSchema_unrecognised_field(self):
     body = get_mock_sign_up_body()
     key = fake.pystr()
     body[key] = fake.pystr()
     assert not sign_up_schema.validate(body)
     assert key not in sign_up_schema.dump(body)