A multipurpose python flask API server and administration SPA
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
712 B

  1. from server.model import User
  2. from server.service import role_service, validation_service
  3. def test_successful_validation():
  4. request_user = User()
  5. request_user.role = role_service.Role.USER
  6. user = User()
  7. user.role = role_service.Role.USER
  8. validation_result = validation_service.validate_model(request_user, user)
  9. assert validation_result.success
  10. def test_failed_validation():
  11. request_user = User()
  12. request_user.role = role_service.Role.ANONYMOUS
  13. user = User()
  14. user.role = role_service.Role.USER
  15. validation_result = validation_service.validate_model(request_user, user)
  16. assert validation_result.success is False
  17. assert 'role' in validation_result.failed