def test_add_sender(): g.db.close() sender = 'patlin' sender_id = vkapi.to_vkid(sender) query = SenderPage.select().where(SenderPage.vkid == sender_id) if (query.exists()): inst = query.get() inst.delete_instance() assertTrue(not query.exists(), __name__) debug_processing('{"type": "message_new",' '"object": {"id": 43,' '"date": 1492522323,' '"out": 0, "user_id": 142872618, "read_state": 0,' '"body": "добавить страницу ' + str(sender) + '"}}') fake_token = 'https://oauth.vk.com/blank.html#access_token=f616432f6d3124e6e0fa29d45818848de94267c747ac20e3a4f5f90d00195da39d2d5f26d218f4211f538' \ '&expires_in=0&user_id=XXXXXXXXX&[email protected]' debug_processing('{"type": "message_new",' '"object": {"id": 43,' '"date": 1492522323,' '"out": 0, "user_id": 69337293, "read_state": 0,' '"body": "' + fake_token + '"}}') query = SenderPage.select().where(SenderPage.vkid == sender_id) assertTrue(query.exists(), __name__) sender = query.get() assertEqual(sender.vkid, sender_id, __name__) sender.delete_instance()
def test_run_sender(): g.db.close() sender = 'patlin' sender_id = vkapi.to_vkid(sender) assertEqual(vkbot_main.vkbot._sender._state, State.stopped, __name__) debug_processing('{"type": "message_new", "object": {"id": 43, "date": 1492522323, ' '"out": 0, "user_id": 142872618, "read_state": 0, ' '"body": ' '"запусти рассылку"}}') assertEqual(vkbot_main.vkbot._sender._state, State.waiting, __name__)
def test_consumer_reply(): g.db.close() user = '******' user_id = vkapi.to_vkid(user) time.sleep(1) debug_processing('{"type": "message_new", "object": {"id": 43, "date": 280679710, ' '"out": 0, "user_id": ' + str(user_id) + ', "read_state": 0, ' '"body": "Ну окей, меня заинтересовал ваш тату-салон."}}') user_page = UserPage.get(UserPage.vkid == user_id) assertEqual(user_page.status, 'active', __name__)
def delete_test_instances(): sender = 'patlin' sender_id = vkapi.to_vkid(sender) sender = SenderPage.get(SenderPage.vkid == sender_id) sender.delete_instance()