Exemple #1
0
 def test_update_missing_pokemon_metadata__calls_tcg_api(self, mock_get_cards_from_database):
     test_path = 'tests/data/test_update_missing_metadata.xlsx'
     shutil.copy2(test_path, excel_copy_path(test_path))
     my_set_sheet = PokemonSetSheet.create(test_pokemon_set, excel_copy_path(test_path))
     update_missing_pokemon_metadata(my_set_sheet)
     mock_get_cards_from_database.assert_called_once_with(test_pokemon_set, [1, 2, 3, 4])
     os.remove(excel_copy_path(test_path))
Exemple #2
0
 def test_get_card_numbers_in_sheet(self):
     test_path = "tests/data/test_get_card_numbers_in_sheet.xlsx"
     shutil.copy2(test_path, excel_copy_path(test_path))
     my_set_sheet = PokemonSetSheet.create(test_pokemon_set,
                                           excel_copy_path(test_path))
     expected_card_numbers = [1, 3, 5, 7, 9]
     actual_card_numbers = my_set_sheet.get_card_numbers_in_sheet()
     assert expected_card_numbers == actual_card_numbers
Exemple #3
0
 def test_update_missing_pokemon_metadata__does_not_call_tcg_api_when_all_required_columns_are_filled \
                 (self, mock_get_cards_from_database):
     test_path = 'tests/data/test_update_missing_metadata__not_called__required_columns_filled.xlsx'
     shutil.copy2(test_path, excel_copy_path(test_path))
     my_set_sheet = PokemonSetSheet.create(test_pokemon_set, excel_copy_path(test_path))
     update_missing_pokemon_metadata(my_set_sheet)
     mock_get_cards_from_database.assert_not_called_with(test_pokemon_set, [2])
     os.remove(excel_copy_path(test_path))
Exemple #4
0
 def test_update_missing_pokemon_metadata__calls_tcg_api_with_missing_card_numbers \
                 (self, mock_get_cards_from_database):
     test_path = 'tests/data/test_update_missing_metadata_v2.xlsx'
     shutil.copy2(test_path, excel_copy_path(test_path))
     pokemon_excel_sheet_model.DEBUG_MODE = False
     my_set_sheet = PokemonSetSheet.create(test_pokemon_set, excel_copy_path(test_path))
     update_missing_pokemon_metadata(my_set_sheet)
     mock_get_cards_from_database.assert_called_once_with(test_pokemon_set, [1, 3, 4])
     os.remove(excel_copy_path(test_path))
     pokemon_excel_sheet_model.DEBUG_MODE = True
Exemple #5
0
 def test_move_existing_columns_to_proper_index(self):
     test_path = 'tests/data/test_pokemon_excel_sheet.xlsx'
     shutil.copy2(test_path, excel_copy_path(test_path))
     my_set_sheet = PokemonSetSheet.create(test_pokemon_set,
                                           excel_copy_path(test_path))
     my_set_sheet.move_existing_columns_out_of_way()
     my_set_sheet.move_existing_columns_to_proper_index()
     poke_column_config = get_poke_columns_config()
     col_config_length = poke_column_config.__len__()
     for i in range(0, col_config_length):
         if poke_column_config[i].name == "4 Owned" or poke_column_config[
                 i].name == "Card #":
             assert_column_is_in_sheet(poke_column_config[i], my_set_sheet)
     os.remove(excel_copy_path(test_path))
Exemple #6
0
 def test_insert_complete_set_metadata__adds_cards_to_sheet(self, mock_get_cards_not_in_list):
     test_path = 'tests/data/test_insert_complete_set_metadata__adds_cards_to_sheet.xlsx'
     shutil.copy2(test_path, excel_copy_path(test_path))
     my_set_sheet = PokemonSetSheet.create(test_pokemon_set, excel_copy_path(test_path))
     index_cards = IndexCards()
     index_cards.cards = [index_card(2, 'Eldegoss V', 'Ultra Rare', 'Grass')]
     mock_get_cards_not_in_list.return_value = index_cards
     insert_complete_set_metadata(my_set_sheet)
     col_1_expected_values = [None, "Eldegoss V"]
     col_4_expected_values = [None, "Ultra Rare"]
     col_5_expected_values = [None, "Grass"]
     assert_values_match_those_in_column(col_1_expected_values, 1, my_set_sheet)
     assert_values_match_those_in_column(col_4_expected_values, 4, my_set_sheet)
     assert_values_match_those_in_column(col_5_expected_values, 5, my_set_sheet)
     os.remove(excel_copy_path(test_path))
Exemple #7
0
 def test_update_missing_pokemon_metadata__should_update_missing_data(self, mock_get_cards_from_database):
     index_cards = IndexCards()
     index_cards.cards = [index_card(1, "Pikachu", "Common", "Electric"),
                          index_card(2, "Raichu", "Uncommon", "Electric"),
                          index_card(3, "Pichu", "Uncommon", "Electric"),
                          index_card(4, "Jigglypuff", "Common", "Normal")]
     mock_get_cards_from_database.return_value = index_cards
     test_path = 'tests/data/test_update_missing_metadata.xlsx'
     shutil.copy2(test_path, excel_copy_path(test_path))
     my_set_sheet = PokemonSetSheet.create(test_pokemon_set, excel_copy_path(test_path))
     update_missing_pokemon_metadata(my_set_sheet)
     col_1_expected_values = ["Pikachu", "Raichu", "Pichu", "Jigglypuff"]
     col_4_expected_values = ["Common", "Uncommon", "Uncommon", "Common"]
     col_5_expected_values = ["Electric", "Electric", "Electric", "Normal"]
     assert_values_match_those_in_column(col_1_expected_values, 1, my_set_sheet)
     assert_values_match_those_in_column(col_4_expected_values, 4, my_set_sheet)
     assert_values_match_those_in_column(col_5_expected_values, 5, my_set_sheet)
     os.remove(excel_copy_path(test_path))
Exemple #8
0
    def test_move_existing_columns_out_of_way(self):
        test_path = 'tests/data/test_move_existing_columns_away.xlsx'
        shutil.copy2(test_path, excel_copy_path(test_path))
        my_set_sheet = PokemonSetSheet.create(test_pokemon_set,
                                              excel_copy_path(test_path))
        my_set_sheet.move_existing_columns_out_of_way()
        poke_column_config_size = get_poke_columns_config().__len__()
        expected_columns = [
            PokeColumn('Card #', 3 + poke_column_config_size),
            PokeColumn('4 Owned', 4 + poke_column_config_size)
        ]

        for i in range(
                poke_column_config_size + 3,
                poke_column_config_size + 3 + expected_columns.__len__()):
            expected_columns_index = i - 3 - poke_column_config_size
            assert my_set_sheet.is_poke_column_in_columns(
                expected_columns[expected_columns_index])
        os.remove(excel_copy_path(test_path))
Exemple #9
0
 def test_insert_missing_columns(self):
     test_path = 'tests/data/test_insert_missing_columns.xlsx'
     shutil.copy2(test_path, excel_copy_path(test_path))
     my_set_sheet = PokemonSetSheet.create(test_pokemon_set,
                                           excel_copy_path(test_path))
     col_2_expected_values = [1, 2, 3, 4]
     col_3_expected_values = ['Yes', 'Yes', 'Yes', 'Yes']
     assert_values_match_those_in_column(col_2_expected_values, 2,
                                         my_set_sheet)
     assert_values_match_those_in_column(col_3_expected_values, 3,
                                         my_set_sheet)
     my_set_sheet.insert_missing_columns()
     # Confirm columns with pre-existing values are unchanged
     assert_values_match_those_in_column(col_2_expected_values, 2,
                                         my_set_sheet)
     assert_values_match_those_in_column(col_3_expected_values, 3,
                                         my_set_sheet)
     poke_column_config = get_poke_columns_config()
     col_config_length = poke_column_config.__len__()
     for i in range(0, col_config_length):
         assert_column_is_in_sheet(poke_column_config[i], my_set_sheet)
     os.remove(excel_copy_path(test_path))