Write get_missing_filenames
This commit is contained in:
parent
dfa7bddf96
commit
07cd251aaa
|
@ -51,6 +51,15 @@ def get_garden_filenames(browser):
|
||||||
def get_local_filenames(directory):
|
def get_local_filenames(directory):
|
||||||
return os.listdir(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):
|
def main(email, password, directory):
|
||||||
browser = initialize_webdriver()
|
browser = initialize_webdriver()
|
||||||
navigate_to_filegarden(browser)
|
navigate_to_filegarden(browser)
|
||||||
|
|
|
@ -125,6 +125,14 @@ class TestJardin(unittest.TestCase):
|
||||||
mockListdir.assert_called_once_with(mockDirectory)
|
mockListdir.assert_called_once_with(mockDirectory)
|
||||||
self.assertEqual(localFiles, mockFiles)
|
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.initialize_webdriver")
|
||||||
@patch("jardin.navigate_to_filegarden")
|
@patch("jardin.navigate_to_filegarden")
|
||||||
@patch("jardin.login_with_password")
|
@patch("jardin.login_with_password")
|
||||||
|
|
Loading…
Reference in New Issue