Пример #1
0
def register():
    request_data = request.get_data()
    try:
        user_data = json.loads(request_data)
        user_fname = user_data['first_name']
        user_lname = user_data['last_name']
        user_name = user_data['username']
        user_email = user_data['email']
        user_pass = user_data['password']
        if len(user_name) < 3 or len(user_name) > 50:
            raise error.LenUserError
        if len(user_email) < 3 or len(user_email) > 255:
            raise error.LenEmailError
        if len(user_pass) < 5 or len(user_pass) > 10 or ' ' in user_pass:
            raise error.LenPassError
        exist_user_email = User.query.filter_by(email=user_email).first()
        if exist_user_email:
            raise error.ExistError2
    except error.LenUserError:
        return json.dumps({'Message': 'Invalid name'}), 400
    except error.LenEmailError:
        return json.dumps({'Message': 'Invalid email'}), 400
    except error.LenPassError:
        return json.dumps({'Message': 'Invalid password'}), 400
    except error.ExistError2:
        return json.dumps({'Message': 'Email existed'}), 400
    user_pass = User.set_password(user_pass)
    user = UserController.create(user_fname, user_lname, user_name, user_email,
                                 user_pass)
Пример #2
0
 def test_create_with_password_missing_capital_letter(self):
     with self.assertRaises(MissingCapitalLetterError):
         UserController.create("KrisiK", "1234567!")
Пример #3
0
 def test_create_with_password_missing_special_symbol(self):
     with self.assertRaises(MissingSpecialSymbolError):
         UserController.create("KrisiK", "1234567K")
Пример #4
0
 def test_create_with_password_length_less_than_8(self):
     with self.assertRaises(LessThanEightSymbolsError):
         UserController.create("KrisiK", "1234K!")
Пример #5
0
import json

USER_CONTROLLER = UserController()
VIDEOGAME_CONTROLLER = VideogameController()
LIBRARY_CONTROLLER = LibraryController()
COMMENT_CONTROLLER = CommentController()

admin_data = {
    'id': 0,
    'username': '******',
    'first_name': 'Usuario',
    'last_name': 'Maestro',
    'password': '******',
    'user_type': 1
}
USER_CONTROLLER.create(admin_data)
user_data = {
    'username': '******',
    'first_name': 'Edgar',
    'last_name': 'Guzman',
    'password': '******',
}
USER_CONTROLLER.create(user_data)


dota_data = {
    'name': 'Dota 2',
    'year': '2013',
    'price': 0.0,
    'category1': 'MOBA',
    'category2': 'Multijugador',