def ps_init(fixtures): echo('Creating tables for `%s@%s`' % (ps_data()['user'], ps_data()['db'])) load_models() # @see https://stackoverflow.com/a/20749534 db.create_all() if fixtures: load_fixtures() return db.session.commit()
def setUp(self): """ Create a test user and a test group in the test database. """ db.drop_all() db.create_all() test_user = User(GenderType.MALE, 'Some', 'User', '*****@*****.**', 'TestToken', 'b4234cd4bed143a6b9bd09e347e17d34', 1) test_user.flat_size = 60.0 test_user.inhabitants = 2 test_user.set_password('some_password1') test_user.state = StateType.ACTIVE db.session.add(test_user) test_user2 = User(GenderType.FEMALE, 'judith', 'greif', '*****@*****.**', 'TestToken2', '52d7c87f8c26433dbd095048ad30c8cf', 1) test_user2.flat_size = 60.0 test_user2.inhabitants = 2 db.session.add(test_user2) test_user3 = User(GenderType.MALE, 'danny', 'stey', '*****@*****.**', 'TestToken3', '117154df05874f41bfdaebcae6abfe98', 1) test_user3.flat_size = 60.0 test_user3.inhabitants = 2 db.session.add(test_user3) db.session.add( Group('TestGroup', '269e682dbfd74a569ff4561b6416c999', '5e769d5b83934bccae11a8fa95e0dc5f', 'e2a7468f0cf64b7ca3f3d1350b893c6d')) db.session.commit() self.client.post('/login', data=json.dumps({ 'user': '******', 'password': '******' }))
def setUp(self): """ Create test users and a test group in the database. """ db.drop_all() db.create_all() self.test_user = User(GenderType.MALE, 'Some', 'User', '*****@*****.**', 'TestToken', 'dca0ec32454e4bdd9ed719fbc9fb75d6', 1) self.test_user.flat_size = 60.0 self.test_user.inhabitants = 2 self.test_user.set_password('some_password1') self.test_user.state = StateType.ACTIVE db.session.add(self.test_user) self.test_user2 = User(GenderType.FEMALE, 'judith', 'greif', '*****@*****.**', 'TestToken2', '6fdbd41a93d8421cac4ea033203844d1', 1) db.session.add(self.test_user2) self.test_user3 = User(GenderType.MALE, 'danny', 'stey', '*****@*****.**', 'TestToken3', 'bf60438327b1498c9df4e43fc9327849', 1) db.session.add(self.test_user3) db.session.add(Group('TestGroup', '0a0f65e992c042e4b86956f3f080114d', '5e769d5b83934bccae11a8fa95e0dc5f', 'e2a7468f0cf64b7ca3f3d1350b893c6d')) db.session.commit() self.client.post('/login', data=json.dumps({'user': '******', 'password': '******'})) self.task = Task()
def setUp(self): db.drop_all() db.create_all() self.test_user = User(GenderType.MALE, 'Some', 'User', '*****@*****.**', 'TestToken', '52d7c87f8c26433dbd095048ad30c8cf', 1) self.test_user.inhabitants = 2 self.test_user.set_password('some_password1') self.test_user.state = StateType.ACTIVE db.session.add(self.test_user) db.session.commit() redis_host = os.environ['REDIS_HOST'] redis_port = os.environ['REDIS_PORT'] redis_db = os.environ['REDIS_DB'] self.redis_client = redis.Redis(host=redis_host, port=redis_port, db=redis_db)
def setUp(self): """ Create test users and a test group in the database. """ db.drop_all() db.create_all() self.test_user = User(GenderType.MALE, 'Some', 'User', '*****@*****.**', 'TestToken', ALL_USER_METER_IDS[0], 1) db.session.add(self.test_user) self.test_user2 = User(GenderType.FEMALE, 'judith', 'greif', '*****@*****.**', 'TestToken2', ALL_USER_METER_IDS[1], 1) db.session.add(self.test_user2) self.test_user3 = User(GenderType.MALE, 'danny', 'stey', '*****@*****.**', 'TestToken3', ALL_USER_METER_IDS[2], 1) db.session.add(self.test_user3) db.session.add( Group('TestGroup', ALL_METER_IDS[3], ALL_METER_IDS[4], ALL_METER_IDS[5])) db.session.commit()
def setUp(self): """ Sets up a fresh database, creates a test user and a test group. """ db.drop_all() db.create_all() self.test_case_user = User(GenderType.MALE, 'Some', 'User', '*****@*****.**', 'TestToken', 'EASYMETER_60404854', 1) self.test_case_user.flat_size = 60.0 self.test_case_user.inhabitants = 2 self.test_case_user.set_password('some_password1') self.test_case_user.state = StateType.ACTIVE self.test_case_user.baseline_state = BaselineStateType.READY db.session.add(self.test_case_user) self.test_case_group = Group("SomeGroup", 'EASYMETER_1124001747', '5e769d5b83934bccae11a8fa95e0dc5f', 'e2a7468f0cf64b7ca3f3d1350b893c6d') db.session.add(self.test_case_user) db.session.add(self.test_case_group) db.session.commit()
def setUp(self): db.drop_all() db.create_all() users_group = Group("SomeGroup", "group_meter_id", '5e769d5b83934bccae11a8fa95e0dc5f', 'e2a7468f0cf64b7ca3f3d1350b893c6d') db.session.add(users_group) db.session.commit() self.target_user = User(GenderType.MALE, "Some", "User", "*****@*****.**", "SomeToken", "SomeMeterId", users_group.id) self.target_user.set_password("some_password1") self.target_user.nick = "SomeNick" self.target_user.name = "SomeName" self.target_user.first_name = "SomeFirstName" self.target_user.state = StateType.ACTIVE self.target_user.baseline_state = BaselineStateType.READY db.session.add(self.target_user) db.session.commit()
def setUp(self): """ Create test user and test PerCapitaConsumprion values in the database. """ db.drop_all() db.create_all() self.test_user = User(GenderType.MALE, 'Some', 'User', '*****@*****.**', 'TestToken', '52d7c87f8c26433dbd095048ad30c8cf', 1) self.test_user.inhabitants = 2 self.test_user.set_password('some_password1') self.test_user.state = StateType.ACTIVE db.session.add(self.test_user) self.base_values = PerCapitaConsumption( DAY_ZERO, self.test_user.meter_id, 0.0, 0.0, 2, 0.0, 0.0, 0, 0.0, 0) self.per_capita_consumption_day_one = PerCapitaConsumption(DAY_ONE, self.test_user.meter_id, 2.1749714, 2.1749714, 2, 1.0874857, 1.0874857, 1, 1.0874857, 397) db.session.add(self.base_values) db.session.add(self.per_capita_consumption_day_one) db.session.commit()
def setUp(self): """ Create test user, test group and load profile in the database. """ db.drop_all() db.create_all() self.test_user = User(GenderType.MALE, 'Some', 'User', '*****@*****.**', 'TestToken', '52d7c87f8c26433dbd095048ad30c8cf', 1) self.test_user.flat_size = 60.0 self.test_user.inhabitants = 2 self.test_user.set_password('some_password1') self.test_user.state = StateType.ACTIVE self.test_user.baseline = 19361634120995 test_first_timestamp = datetime(2020, 2, 13, 9, 57, 3) test_first_user_saving = UserSaving( test_first_timestamp, '52d7c87f8c26433dbd095048ad30c8cf', 3148577026610.7812) test_second_timestamp = datetime(2020, 1, 13, 9, 57, 3) test_second_user_saving = UserSaving( test_second_timestamp, '52d7c87f8c26433dbd095048ad30c8cf', 3259689137721.8923) test_first_community_saving = CommunitySaving(test_first_timestamp, 85184267259376.5) test_second_community_saving = CommunitySaving(test_second_timestamp, 86295378361487.6) db.session.add(self.test_user) db.session.add(test_first_user_saving) db.session.add(test_second_user_saving) db.session.add(test_first_community_saving) db.session.add(test_second_community_saving) db.session.commit() self.client.post('/login', data=json.dumps({ 'user': '******', 'password': '******' }))
def setUp(self): db.drop_all() db.create_all() db.session.add(User(GenderType.MALE, "Some", "User", "*****@*****.**", "SomeToken", "SomeMeterId", "SomeGroup")) db.session.commit()
def setUp(self): db.drop_all() db.create_all()