def test__storage_card_works_for_created_cards(self): db = MyCardShelveAdmin(self.db_source, self.db_key) cardsList_1 = self.textAdmin.return_sources() db.update_sources(cardsList_1) cardsList_2 = db.return_sources() cards = [card.representation for card in cardsList_1] expected = [card.representation for card in cardsList_2] self.assertEqual(expected, cards)
def setUp(self): self.text_src = filled_text_path self.text_src_before = get_from_txt(self.text_src) writer = DictBasedCardWriter() self.textAdmin = TextSourceAdmin(config_file_path, writer) self.db_source = os.path.join(SAMPLE_FOLDER, "db_cards_test") self.db_key = "test_key" self.db_source_before = [] self.db_admin = MyCardShelveAdmin(self.db_source, self.db_key)
def test__update_source_when_all_cards_was_inserted(self): db = MyCardShelveAdmin(self.db_source, self.db_key) card_list = self.textAdmin.return_sources() db.update_sources(card_list) for card in card_list: card.inserted = True db.update_sources(card_list) expected = db.return_sources() self.assertEqual(expected, [])
def test__update_source_when_last_card_was_not_inserted(self): db = MyCardShelveAdmin(self.db_source, self.db_key) card_list = self.textAdmin.return_sources() db.update_sources(card_list) for i in range(len(card_list) - 1): card_list[i].inserted = True last_card = card_list[-1].representation db.update_sources(card_list) db_return = db.return_sources() expected = db_return[0].representation self.assertEqual(expected, last_card)
from src.clss.sourceAdmins import MyCardShelveAdmin from . import CONFIG_FILE path = os.path.join(os.getcwd(), 'data.json') folder_path = login_path = path writer = DictBasedCardWriter() img_source = LocalFolderSource(CONFIG_FILE) text_extractor = GoogleVision() wdconfig = WebDriverConfigurator(CONFIG_FILE) selenium_anki_bot_args = { 'web_driver_settings': wdconfig, 'user_data': CONFIG_FILE } deliver = SeleniumAnkiBot(**selenium_anki_bot_args) #deliver = SeleniumAnkiBot(Firefox, login_path) img_admin = ImageSourceAdmin(img_source, writer, text_extractor) db = MyCardShelveAdmin('db', 'cards') automaton = AutoFlashCards(deliver, img_admin, db) if __name__ == "__main__": automaton.run_task() if len(automaton.card_list) == 0: print('No cards to create.')
def test__update_source_returns_None_when_no_given_cards(self): EMPTY_LIST = [] db = MyCardShelveAdmin(self.db_source, self.db_key) expected = db.update_sources(EMPTY_LIST) self.assertEqual(expected, None)