From bf3a7db6cf83fa7d224d84c47b40cfe32603019c Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Wed, 15 Nov 2023 10:36:18 -0800 Subject: Convert File.dest from a string to a Path (#14) --- tests/test_dl.py | 4 ++-- tests/test_file_class.py | 6 +++--- tests/test_parse.py | 4 ++-- tests/test_validations.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/test_dl.py b/tests/test_dl.py index cb5f0b6..cb893b8 100644 --- a/tests/test_dl.py +++ b/tests/test_dl.py @@ -375,7 +375,7 @@ class TestDownload: with patch("wikiget.dl.verify_hash") as mock_verify_hash: mock_verify_hash.return_value = "d01b79a6781c72ac9bfff93e5e2cfbeef4efc840" - args = parse_args(["-o", tmp_file, "File:Example.jpg"]) + args = parse_args(["-o", str(tmp_file), "File:Example.jpg"]) errors = download(mock_file, args) assert caplog.record_tuples[0] == ( @@ -414,7 +414,7 @@ class TestDownload: If the downloaded file cannot be created, an error log message should be created with details on the exception. """ - with patch("wikiget.dl.Path.open") as mock_open: + with patch("pathlib.Path.open") as mock_open: mock_open.side_effect = OSError("write error") args = parse_args(["File:Example.jpg"]) errors = download(mock_file, args) diff --git a/tests/test_file_class.py b/tests/test_file_class.py index 8e68239..a8afe55 100644 --- a/tests/test_file_class.py +++ b/tests/test_file_class.py @@ -30,7 +30,7 @@ class TestFileClass: def test_file_with_name_dest(self, file_with_name: File) -> None: """The file dest attribute should be the same as the name.""" - assert file_with_name.dest == file_with_name.name + assert file_with_name.dest.match(file_with_name.name) def test_file_with_name_site(self, file_with_name: File) -> None: """The file site attribute should equal the default site.""" @@ -38,11 +38,11 @@ class TestFileClass: def test_file_with_name_and_dest(self, file_with_name_and_dest: File) -> None: """The file dest attribute should equal what was passed in.""" - assert file_with_name_and_dest.dest == "bazqux.jpg" + assert file_with_name_and_dest.dest.match("bazqux.jpg") def test_name_and_dest_are_different(self, file_with_name_and_dest: File) -> None: """The file name and dest attributes should not be the same.""" - assert file_with_name_and_dest.dest != file_with_name_and_dest.name + assert not file_with_name_and_dest.dest.match(file_with_name_and_dest.name) def test_file_with_name_and_site(self) -> None: """Test the attributes of a File created with a name and site. diff --git a/tests/test_parse.py b/tests/test_parse.py index fb824d4..bec2113 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -60,7 +60,7 @@ class TestGetDest: Unless otherwise specified, it should match the filename. """ - assert file_with_filename.dest == "Example.jpg" + assert file_with_filename.dest.match("Example.jpg") def test_get_dest_site_with_filename(self, file_with_filename: File) -> None: """Test that the file's site attribute is set correctly. @@ -88,7 +88,7 @@ class TestGetDest: def test_get_dest_with_url(self, file_with_url: File) -> None: """Test that the file's dest attribute is set correctly.""" - assert file_with_url.dest == "Example.jpg" + assert file_with_url.dest.match("Example.jpg") def test_get_dest_site_with_url(self, file_with_url: File) -> None: """Test that the file's site attribute is set correctly. diff --git a/tests/test_validations.py b/tests/test_validations.py index aa4fdd0..072858e 100644 --- a/tests/test_validations.py +++ b/tests/test_validations.py @@ -170,4 +170,4 @@ class TestVerifyHash: """ expected_sha1 = "cd19c009a30ca9b68045415a3a0838e64f3c2443" - assert verify_hash(str(test_file)) == expected_sha1 + assert verify_hash(test_file) == expected_sha1 -- cgit v1.2.3