Return the reason a username validation failed and add tests to verify we are sending the reason to client
This commit is contained in:
parent
a71c682abe
commit
0e54b0501c
3 changed files with 39 additions and 11 deletions
|
@ -292,6 +292,24 @@ class TestCreateNewUser(ApiTestCase):
|
|||
expected_code=400)
|
||||
|
||||
self.assertEquals('The username already exists', json['message'])
|
||||
|
||||
def test_trycreatetooshort(self):
|
||||
json = self.postJsonResponse(User,
|
||||
data=dict(username='a',
|
||||
password='password',
|
||||
email='test@example.com'),
|
||||
expected_code=400)
|
||||
|
||||
self.assertEquals('Invalid username a: Username must be between 4 and 30 characters in length', json['error_description'])
|
||||
|
||||
def test_trycreateregexmismatch(self):
|
||||
json = self.postJsonResponse(User,
|
||||
data=dict(username='auserName',
|
||||
password='password',
|
||||
email='test@example.com'),
|
||||
expected_code=400)
|
||||
|
||||
self.assertEquals('Invalid username auserName: Username must match expression [a-z0-9_]+', json['error_description'])
|
||||
|
||||
def test_createuser(self):
|
||||
data = self.postResponse(User,
|
||||
|
|
Reference in a new issue