Example #1
0
def client():
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    db.init_app(app)
    db.create_all(app=app)
    new_ticket = {
        "name": "Christian",
        "email": "*****@*****.**",
        "subject": "why is not working?",
        "type": "Bug",
        "urgency": "Low",
        "message": "ciao"
    }
    new_comment = {
        "message": "Thanks for your message this should be resolved."
    }
    ticket_schema, err = schema.Ticket().load(new_ticket)
    with app.app_context():
        ticket = models.Ticket(**ticket_schema)
        comment = models.Comment(**new_comment)
        ticket.comments.append(comment)
        db.session.add(ticket)
        db.session.commit()

    with app.test_client() as c:
        yield c
Example #2
0
def init_db():
    """Initialize database"""
    from factory import db, app
    app = create_app('default')
    app_context = app.app_context()
    app_context.push()
    db.create_all()
    from catalog.init_db import database_init
    x = database_init.fill_examples
    x()
    app_context.pop()
Example #3
0
    def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        self.client = self.app.test_client(use_cookies=True)

        # signup a new user
        response = self.client.post(url_for('catalog.signup'), data= {
            'username': '******',
            'password': '******',
            'verify':   '123',
        })
        self.assertTrue(response.status_code == 302)
Example #4
0
def create_dummy_db():
    '''
    Some dummy users will be created and assigned roles: The names and roles
    of the dummy users are as stated above, i.e,
    Authour is assigned username='******', email='*****@*****.**', and
    password='******'
    '''
    with app.app_context():
        from users_module import user_datastore, User, Role
        user_datastore = SQLAlchemyUserDatastore(db, User, Role)
        # Create the tables, if they don't exist
        db.create_all()
        # Create the Roles
        create_roles(user_datastore)
        # Create four Users for testing and debugging purposes
        create_users(user_datastore)
        create_currencies()
        create_dispatchers()
        create_stores()
        create_products()
        # Committing seems to be the beat optuion here,
        # as nothing will be committed is any constraint is breached
        db.session.commit()
Example #5
0
def before_first_request():
    db.create_all()
Example #6
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
Example #7
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     self.client = self.app.test_client(use_cookies=True)