Beispiel #1
0
 def test_update_new_username(self):
     # update to a new username
     before = User(**updated_user1)
     before.username = '******'
     AccountManager.update_user(user1['username'], before)
     after = get_user(before.username)
     self.assertDictEqual(after.to_dict(), before.to_dict())
Beispiel #2
0
def get_user(username):
    # Get info from database
    doc_data = {'collection_name': 'users', 'document_id': username}
    r = requests.get(database_url, json=doc_data)
    if r.status_code == requests.codes.ok:
        user_js = r.json()
        return User(**user_js)
    return None
Beispiel #3
0
 def test_deleted_prev(self):
     # update to a new username
     user = User(**updated_user1)
     user.username = '******'
     AccountManager.update_user(user1['username'], user)
     self.assertIsNone(get_user(user1['username']))
Beispiel #4
0
 def test_update_invalid_param(self):
     self.assertFalse(AccountManager.update_user(5, User('user')))
Beispiel #5
0
 def test_update_nonexistent(self):
     self.assertFalse(
         AccountManager.update_user('notauser', User(**bare_user)))
Beispiel #6
0
 def test_username_taken(self):
     self.assertFalse(
         AccountManager.update_user(user1['username'], User(**user2)))
Beispiel #7
0
 def test_update_user(self):
     # update everything but keep the username
     AccountManager.update_user(user1['username'], User(**updated_user1))
     user = get_user(user1['username']).to_dict()
     self.assertDictEqual(user, updated_user1)
Beispiel #8
0
 def make_user(self, data):
     return User(**data)