From ce58a03caa6f4d9e3cb01898b4b73716031b24dd Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Thu, 16 Nov 2023 09:47:27 -0800 Subject: Add tests for file string methods --- tests/test_file_class.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_file_class.py b/tests/test_file_class.py index a8afe55..4ad06d1 100644 --- a/tests/test_file_class.py +++ b/tests/test_file_class.py @@ -73,3 +73,22 @@ class TestFileComparison: """ not_a_file = {"name": "foobar.jpg", "dest": "foobar.jpg"} assert file_with_name.__eq__(not_a_file) == NotImplemented + + +class TestFileStrings: + """Define tests related to wikiget.file.File string representations.""" + + def test_file_str(self, file_with_name: File) -> None: + """Test that str(File) produces the correct output.""" + expected_output = ( + "{'name': 'foobar.jpg', 'dest': PosixPath('foobar.jpg'), " + "'site': 'commons.wikimedia.org', 'image': None}" + ) + assert str(file_with_name) == expected_output + + def test_file_repr(self, file_with_name: File) -> None: + """Test that repr(File) produces the correct output.""" + expected_output = ( + 'File("foobar.jpg", "foobar.jpg", "commons.wikimedia.org", None)' + ) + assert repr(file_with_name) == expected_output -- cgit v1.2.3