def test_create_table_if_it_doesnot_exist(self): with (yield from self.pool) as conn: cur = yield from conn.cursor() yield from cur.execute("show tables like 'current_cost'") current_cost_table = yield from cur.fetchall() self.assertEqual((('current_cost', ), ), current_cost_table) MysqlCurrentCostMessageHandler(self.pool, average_period_minutes=10) yield from cur.execute("show tables like 'current_cost'") current_cost_table = yield from cur.fetchall() self.assertEquals((('current_cost', ), ), current_cost_table) yield from cur.close()
def run_application(mysq_pool, config): # backend redis_pool_ = yield from create_redis_pool() daq_rfxcom = yield from create_rfxtrx433e(config['rfxcom']) current_cost = create_current_cost(redis_pool_, config['current_cost']) current_cost_recorder = AsyncRedisSubscriber( redis_pool_, MysqlCurrentCostMessageHandler(mysq_pool, average_period_minutes=10), CURRENT_COST_KEY).start() pool_temp_recorder = AsyncRedisSubscriber( redis_pool_, MysqlTemperatureMessageHandler(mysq_pool, 'pool_temperature', average_period_minutes=10), RFXCOM_KEY).start()
def setUp(self): self.pool = yield from aiomysql.create_pool(host='127.0.0.1', port=3306, user='******', password='******', db='test', loop=self.loop) self.message_handler = MysqlCurrentCostMessageHandler(self.pool) self.current_cost_service = CurrentCostDatabaseReader( self.pool, time(8, 0), time(22, 0)) current_cost_mysql_service.now = lambda: datetime( 2015, 6, 1, 12, 0, 0, tzinfo=get_localzone()) with (yield from self.pool) as conn: cur = yield from conn.cursor() yield from cur.execute("truncate current_cost")
def setUp(self): self.pool = yield from aiomysql.create_pool( host='127.0.0.1', port=3306, user='******', password='******', db='test', loop=asyncio.get_event_loop()) with (yield from self.pool) as conn: cur = yield from conn.cursor() yield from cur.execute("drop table if EXISTS current_cost") yield from cur.close() redis_toolbox.now = lambda: datetime( 2012, 12, 13, 14, 2, 0, tzinfo=timezone.utc) self.message_handler = MysqlCurrentCostMessageHandler(self.pool)
def setUp(self): self.pool = yield from aiomysql.create_pool( host='127.0.0.1', port=3306, user='******', password='******', db='test', loop=asyncio.get_event_loop()) self.server = yield from domopyc_server.init(asyncio.get_event_loop(), self.pool, port=12345) self.message_handler = MysqlCurrentCostMessageHandler(self.pool) with (yield from self.pool) as conn: cur = yield from conn.cursor() yield from cur.execute("truncate current_cost") yield from cur.close()