def test_register_line_sticker(self, command, ans): self._mock_bot.sendMessage = asynctest.Mock( side_effect=MockTelepot.mock_send_message) self._mock_bot.getMe = asynctest.Mock( side_effect=MockTelepot.mock_get_me) sticker = Sticker(self._mock_bot, TEST_USER_NAME, TEST_USER_ID, TEST_CHAT_ID) sticker.create_sticker_set = asynctest.Mock( side_effect=self.mock_create_sticker_set) StickerStore.insert_sticker_info = MagicMock( side_effect=self.mock_insert_sticker_info) StickerStore.fetch_line_sticker_info = MagicMock( side_effect=self.mock_fetch_line_sticker_info) loop = asyncio.get_event_loop() actual = loop.run_until_complete( sticker.register_line_sticker(command)) assert actual is ans
def test_create_sticker_set(self, sticker_title, sticker_set_name, ans): sticker = Sticker(self._mock_bot, TEST_USER_NAME, TEST_USER_ID, TEST_CHAT_ID) for filename in glob.glob('./tests/static/png/*.*'): shutil.copy(filename, sticker._sticker_dir) self._mock_bot.uploadStickerFile = asynctest.Mock( side_effect=MockTelepot.mock_upload_sticker_file) self._mock_bot.createNewStickerSet = asynctest.Mock( side_effect=MockTelepot.mock_create_new_sticker_set) self._mock_bot.addStickerToSet = asynctest.Mock( side_effect=MockTelepot.mock_add_sticker_to_set) sticker.delete_sticker_set = asynctest.Mock( side_effect=self.mock_delete_sticker_set) loop = asyncio.get_event_loop() actual = loop.run_until_complete( sticker.create_sticker_set(sticker_title, sticker_set_name)) assert actual is ans