Skip to content

Commit

Permalink
Merge pull request #5890 from drew2a/fix/test_download_load_corrupt
Browse files Browse the repository at this point in the history
Change mocked config to corrupted source file
  • Loading branch information
drew2a committed Dec 29, 2020
2 parents 5af797b + 4a953b5 commit da3cbf7
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,7 @@

CONFIG_PATH = TESTS_DATA_DIR / "config_files"


@pytest.fixture(name='faulty_download_config_parser')
async def fixture_faulty_download_config_parser():
def load_config_with_parse_error(filename):
raise ConfigObjParseError(f"Error parsing config file {filename}")

original_load_config = DownloadConfig.load
DownloadConfig.load = load_config_with_parse_error
yield DownloadConfig
DownloadConfig.load = original_load_config


def test_convert_state_file_to_conf75_with_parse_error(tmpdir, faulty_download_config_parser):
def test_convert_state_file_to_conf75_with_parse_error(tmpdir):
"""
Tests conversion of the conf files (7.4.0) files to .conf files (7.5) when there is parsing error.
ParseError happens for some users for some unknown reason. We simply remove the files that we cannot
Expand All @@ -36,7 +24,7 @@ def test_convert_state_file_to_conf75_with_parse_error(tmpdir, faulty_download_c
os.makedirs(state_dir / STATEDIR_CHECKPOINT_DIR)

# Copy Ubuntu conf file with corrupted metainfo data
src_path = CONFIG_PATH / "13a25451c761b1482d3e85432f07c4be05ca8a56.conf"
src_path = CONFIG_PATH / "corrupt_download_config.conf"
dest_path = state_dir / STATEDIR_CHECKPOINT_DIR / "ubuntu_corrupted.conf"
shutil.copyfile(src_path, dest_path)

Expand Down

0 comments on commit da3cbf7

Please sign in to comment.