forked from hasgeek/lastuser
/
runtestserver.py
36 lines (30 loc) · 1.21 KB
/
runtestserver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from lastuserapp import app, db
from lastuser_core.models import User, Organization, Client, Permission
# incase data exists from previously run tests
db.drop_all()
# create schema again
db.create_all()
# Add fixtures for test app
# user for CRUD workflow: creating client app
gustav = User(username=u"gustav", fullname=u"Gustav 'world' Dachshund", password='worldismyball')
# org for associating with client
# client for CRUD workflow of defining perms *in* client
# spare user for CRUD workflow of assigning permissions
oakley = User(username=u"oakley", fullname=u"Oakley 'huh' Dachshund")
dachsunited = Organization(name=u"dachsunited", title=u"Dachs United")
dachsunited.owners.users.append(gustav)
dachsunited.members.users.append(oakley)
dachshundworld = Client(title=u"Dachshund World", org=dachsunited, confidential=True, website=u"http://gustavsdachshundworld.com")
partyanimal = Permission(name=u"partyanimal", title=u"Party Animal", org=dachsunited)
db.session.add(gustav)
db.session.add(oakley)
db.session.add(dachsunited)
db.session.add(dachshundworld)
db.session.add(partyanimal)
db.session.commit()
app.run('0.0.0.0')