Beispiel #1
0
    def setUp(self):
        self.app = create_application(config_override=TestConfig)

        self.db_fb, self.app.config['DATABASE'] = tempfile.mkstemp()

        self.app.testing = True

        with self.app.app_context():
            import mobile.models
            db.create_all(app=self.app)

        self.app_context = self.app.app_context()
        self.app_context.push()
Beispiel #2
0
    'Office Admin': ['Receptionist', 'Office Assistant', 'Office Manager'],
    'Tutoring': [
        'French Tutoring',
        'English Tutoring',
    ],
    'Labour': [
        'General Labour',
    ],
    'IT': ['Graphic Designer', 'Developer', 'Support / QA']
}

if __name__ == "__main__":

    try:
        print("Creating database, please wait.")
        db.create_all(app=application)
    except:
        print("Database exists; Operation resumed")

    # With so we have the app context.
    with application.app_context():
        # Query database first and see if the items exist
        # if the database is populated with items, exit script
        # otherwise insert the default values.

        for key, value in job_type_categories.items():
            category = JobCategory.query.filter_by(name=key).first()

            if category is None:
                category = JobCategory(name=key)
                category.save(commit=True)