def project(session): """ links up a Project with releases, tags, and comments for testing. """ import datetime from pygameweb.project.models import Project, Release, Projectcomment, Tags from pygameweb.user.models import User, Group user = User(name="name", email="email", password="", disabled=0, active=True) the_project = Project( title="Stuntcat", summary="Summary of some project 1.", description="Description of some project.", uri="http://some.example.com/", datetimeon=datetime.datetime(2017, 1, 5), image="1.png", github_repo="https://github.com/pygame/stuntcat", user=user, ) tag1 = Tags(project=the_project, value="game") tag2 = Tags(project=the_project, value="arcade") session.add(tag1) session.add(tag2) release1 = Release( datetimeon=datetime.datetime(2017, 1, 5), description="Some release.", srcuri="http://example.com/source.tar.gz", winuri="http://example.com/win.exe", macuri="http://example.com/mac.dmg", version="A release title.", ) release2 = Release( datetimeon=datetime.datetime(2017, 1, 6), description="Some release with new things.", srcuri="http://example.com/source.tar.gz", winuri="http://example.com/win.exe", macuri="http://example.com/mac.dmg", version="A second release title.", ) the_project.releases.append(release1) the_project.releases.append(release2) comment1 = Projectcomment(user=user, content="Some comment 1.", rating=5) comment2 = Projectcomment(user=user, content="Some comment 2.", rating=3) the_project.comments.append(comment1) the_project.comments.append(comment2) session.add(the_project) session.commit() return the_project
def user(app, session, wiki_client): """ gives us a user who is a member. """ from pygameweb.user.models import User from flask_security.utils import encrypt_password user = User(name='joe', email='*****@*****.**', password=encrypt_password('password')) session.add(user) session.commit() # https://flask-login.readthedocs.org/en/latest/#fresh-logins with wiki_client.session_transaction() as sess: sess['user_id'] = user.id sess['_fresh'] = True return user
def a_user(app, session, project_client, name, email, logged_in, disabled, active): """ gives us a user who is a member. """ from pygameweb.user.models import User, Group from flask_security.utils import encrypt_password group = Group(name='members', title='Member') user = User(name=name, email=email, password=encrypt_password('password'), disabled=disabled, active=active, roles=[group]) session.add(user) session.commit() # https://flask-login.readthedocs.org/en/latest/#fresh-logins with project_client.session_transaction() as sess: sess['user_id'] = user.id sess['_fresh'] = True return user