Write get_missing_filenames

This commit is contained in:
The Magician 2023-10-20 20:03:39 +01:00
parent dfa7bddf96
commit 07cd251aaa
2 changed files with 17 additions and 0 deletions

View File

@ -51,6 +51,15 @@ def get_garden_filenames(browser):
def get_local_filenames(directory):
return os.listdir(directory)
def get_missing_filenames(localFiles, gardenFiles):
missingFilenames = []
for localFile in localFiles:
if localFile not in gardenFiles:
missingFilenames.append(localFile)
return missingFilenames
def main(email, password, directory):
browser = initialize_webdriver()
navigate_to_filegarden(browser)

View File

@ -125,6 +125,14 @@ class TestJardin(unittest.TestCase):
mockListdir.assert_called_once_with(mockDirectory)
self.assertEqual(localFiles, mockFiles)
def test_get_missing_filenames_returns_local_filenames_without_garden_filenames(self):
mockLocalFilenames = ["file1.jpg", "file2.jpg", "file3.jpg", "file4.jpg", "file5.jpg"]
mockGardenFilenames = ["file2.jpg", "file4.jpg", "file6.jpg", "file8.jpg", "file10.jpg"]
missingFilenames = jardin.get_missing_filenames(mockLocalFilenames, mockGardenFilenames)
self.assertEqual(missingFilenames, ["file1.jpg", "file3.jpg", "file5.jpg"])
@patch("jardin.initialize_webdriver")
@patch("jardin.navigate_to_filegarden")
@patch("jardin.login_with_password")