示例#1
0
def deploy():
    """run deployment tasks"""
    from flask.ext.migrate import upgrade
    from app.models.user import Role

    print(config_name)

    upgrade()
    Role.insert_roles()
示例#2
0
def deploy():
    """run deployment tasks"""
    from flask.ext.migrate import upgrade
    from app.models.user import Role

    print(config_name)

    upgrade()
    Role.insert_roles()
示例#3
0
    def test_project_create(self):
        """ Test project creation """
        data = dict(
            title="An Experiment",
            difficulty=1,
            time_required="5 minutes",
            abstract="Create an experiment in 5 mins.",
            objective="The objective is to create something.",
            safety="No safety hazards",
            content="Start with the project, finish in 5 mins.",
            category_id=1,
        )

        from app.models.user import User, Role

        # Create a mock user
        Role.insert_roles()
        creator = Role.query.filter_by(name="Creator").first()
        user = User(username="******", role=creator)

        db.session.add(user)
        db.session.commit()

        access_token = create_access_token(identity=user.id)

        create_resp = create_project(self, access_token, data)
        create_resp_data = json.loads(create_resp.data.decode())

        project = create_resp_data["project"]

        self.assertTrue(create_resp.status)
        self.assertEqual(create_resp.status_code, 201)

        # Remove category id
        data.pop("category_id")

        # Check if each field matches.
        for field in data:
            self.assertEqual(project[field], data[field])

        # Test for bad request
        data.pop("title")
        bad_create_resp = create_project(self, access_token, data)

        self.assertEqual(bad_create_resp.status_code, 400)
 def setUp(self):
     # Extend setUp
     super(TestUserModel, self).setUp()
     Role.insert_roles()
示例#5
0
from app import  db
from app.models.user import Role, User
from app.models.event import Event
 
 

wam="austin"
 
   
db.drop_all()
db.create_all()
db.session.commit()
 
Role.insert_roles()

user = User(username='******', fullname='Account', password="******",email='austinwam',  role_id=3)
user1 = User(username='******', fullname='Account', password="******",email='austinwam3',  role_id=3)
user2 = User(username='******', fullname='Account', password="******",email='austinwam4',  role_id=3)
user3 = User(username='******', fullname='Account', password="******",email='austinwam1',  role_id=2)
user4 = User(username='******', fullname='Account', password="******",email='austinwam2',  role_id=2)
event = Event(location='othaya',title='immunatioztion', date='1241993',)
db.session.add(user)
db.session.add(user1)
db.session.add(user2)
db.session.add(user4)
db.session.add(user3)
db.session.add(event)


db.session.commit()
print('Added administrator')