def setUp(self): self.app = app.app.test_client() dbmodels.create_tables() # create test structures self.test_group1 = {'name': 'schwingers'} self.app.post('/groups', data=json.dumps(self.test_group1), headers={'content-type': 'application/json'}) self.test_group2 = {'name': 'hammers'} self.app.post('/groups', data=json.dumps(self.test_group2), headers={'content-type': 'application/json'}) self.test_user1 = { 'first_name': 'IP', 'last_name': 'freely', 'userid': 'dobby', 'groups': ['schwingers', 'hammers'] } self.app.post('/users', data=json.dumps(self.test_user1), headers={'content-type': 'application/json'}) self.test_user2 = { 'first_name': 'john', 'last_name': 'schwinghammer', 'userid': 'jschwing', 'groups': ['schwingers', 'hammers'] } self.app.post('/users', data=json.dumps(self.test_user2), headers={'content-type': 'application/json'})
def setUp(self): self.app = app.app.test_client() dbmodels.create_tables() # create test group self.test_group = {'name': 'schwingers'} self.app.post('/groups', data=json.dumps(self.test_group), headers={'content-type': 'application/json'})
def setUp(self): self.app = app.app.test_client() dbmodels.create_tables() # add test user self.test_user = { 'first_name': 'john', 'last_name': 'schwinghammer', 'userid': 'jschwing', 'groups': [] } self.app.post('/users', data=json.dumps(self.test_user), headers={'content-type': 'application/json'})
def setUp(self): self.app = app.app.test_client() # dbmodels.db.init_app(app) # with app.app_context(): dbmodels.create_tables() # create test structures g = {'name': 'schwingers'} self.app.post('/groups', data=json.dumps(g), headers={'content-type': 'application/json'}) g = {'name': 'hammers'} self.app.post('/groups', data=json.dumps(g), headers={'content-type': 'application/json'}) u = { 'first_name': 'IP', 'last_name': 'freely', 'userid': 'dobby', 'groups': [] } self.app.post('/users', data=json.dumps(u), headers={'content-type': 'application/json'})
def configure_logging(): """ i hate python logging so, so much... :/ """ # disable the stupid werkzeug logger l = logging.getLogger('werkzeug') l.setLevel(10000) # have to completely disable flask's handlers because they can't be # removed for some reason for h in LOG.handlers: h.setLevel(10000) # set my own format instead of the awful multiline flask awfulness fmt = logging.Formatter('[%(asctime)s] {%(filename)s:%(lineno)d} ' '%(levelname)s - %(message)s') sh = logging.StreamHandler() sh.setLevel(logging.DEBUG) sh.setFormatter(fmt) LOG.setLevel(logging.DEBUG) LOG.addHandler(sh) if __name__ == '__main__': #app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:' app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL'] configure_logging() dbmodels.create_tables() port = os.environ.get('PORT', 5000) app.run(host='0.0.0.0', port=port)