def test_get_by_id(self): """Get user by ID.""" user = User('foo', '*****@*****.**') user.save() retrieved = User.get_by_id(user.id) assert retrieved == user
def registerapi(): json_data = request.json user = User( username=json_data['username'], email=json_data['email'], password=json_data['password'] ) try: db.session.add(user) db.session.commit() status = 'success' except: status = 'this user is already registered' db.session.close() return jsonify({'result': status})
def test_password_is_nullable(self): user = User(username='******', email='*****@*****.**') user.save() assert user.password is None
def test_created_at_defaults_to_datetime(self): user = User(username='******', email='*****@*****.**') user.save() assert bool(user.created_at) assert isinstance(user.created_at, dt.datetime)
def test_password_is_nullable(self): """Test null password.""" user = User(username="******", email="*****@*****.**") user.save() assert user.password is None
def test_created_at_defaults_to_datetime(self): """Test creation date.""" user = User(username="******", email="*****@*****.**") user.save() assert bool(user.created_at) assert isinstance(user.created_at, dt.datetime)