def _create_and_update_local_user_if_needed(self, user_data): gapi_id = user_data["id"] session_db = self._database.get_session() user = self._database.get_user(gapi_id=gapi_id) thumbnail_url = user_data["image"]["url"] profile_pic_url = user_data["image"]["url"].replace("sz=50", "sz=200") if user: logger.info("User already exists locally.") user.thumbnail_url = thumbnail_url user.profile_pic_url = profile_pic_url else: logger.info("Creating user %s", gapi_id) user = User( gapi_id=gapi_id, name=user_data["displayName"], thumbnail_url=thumbnail_url, profile_pic_url=profile_pic_url, ) session_db.add(user) session_db.commit() intro_msg = Message( sender=self._database.\ get_user(gapi_id=self._database.my_gapi_id).id, receiver=user.id, msg_data="Welcome to my site!", datetime_sent=self._platform.time_datetime_now(), ) session_db.add(intro_msg) session_db.commit() # save return user
from app.view.view import check_password from app.model.model import User if __name__ == '__main__': u = User() u.set_password('puha') b = check_password('puha', u) print('What an app..')
def test_user_id(): u = User() assert (u.id == '000')
def test_user_home_url(): u = User() assert (isinstance(u.get_home_url(), Url))
def test_superuser_password(): u = User() u.set_password('puha') assert (u.password == 'puha')
def test_superuser_span(): u = User() homepage = u.span_homepage_html_title() assert ('span' in homepage)
def test_check_password(): u = User() u.set_password('puha') assert(check_password('puha', u) is True)