Take local directory name as cli argument

This commit is contained in:
The Magician 2023-10-20 18:40:40 +01:00
parent eac6deee1d
commit dfa7bddf96
2 changed files with 8 additions and 3 deletions

View File

@ -51,15 +51,16 @@ def get_garden_filenames(browser):
def get_local_filenames(directory): def get_local_filenames(directory):
return os.listdir(directory) return os.listdir(directory)
def main(email, password): def main(email, password, directory):
browser = initialize_webdriver() browser = initialize_webdriver()
navigate_to_filegarden(browser) navigate_to_filegarden(browser)
login_with_password(browser, email, password) login_with_password(browser, email, password)
click_go_to_your_garden(browser) click_go_to_your_garden(browser)
garden_filenames = get_garden_filenames(browser) garden_filenames = get_garden_filenames(browser)
get_local_filenames(directory)
# Get list of files in target upload directory that don't exist in File Garden (test based on filename? size? file contents?) # Get list of files in target upload directory that don't exist in File Garden (test based on filename? size? file contents?)
# For each file in the second list, go through the file upload process # For each file in the second list, go through the file upload process
#browser.close() #browser.close()
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv[1], sys.argv[2]) main(sys.argv[1], sys.argv[2], sys.argv[3])

View File

@ -130,7 +130,9 @@ class TestJardin(unittest.TestCase):
@patch("jardin.login_with_password") @patch("jardin.login_with_password")
@patch("jardin.click_go_to_your_garden") @patch("jardin.click_go_to_your_garden")
@patch("jardin.get_garden_filenames") @patch("jardin.get_garden_filenames")
@patch("jardin.get_local_filenames")
def test_main_calls_methods_in_correct_order(self, def test_main_calls_methods_in_correct_order(self,
mockGetLocalFilenames,
mockGetGardenFilenames, mockGetGardenFilenames,
mockClickGoToYourGarden, mockClickGoToYourGarden,
mockLoginWithPassword, mockLoginWithPassword,
@ -138,14 +140,16 @@ class TestJardin(unittest.TestCase):
mockInitializeWebdriver): mockInitializeWebdriver):
mockEmail = "email@mail.com" mockEmail = "email@mail.com"
mockPassword = "p4$$w0rd" mockPassword = "p4$$w0rd"
mockDirectory = "/home/luser/gardenfiles/"
jardin.main(mockEmail, mockPassword) jardin.main(mockEmail, mockPassword, mockDirectory)
mockInitializeWebdriver.assert_called_once() mockInitializeWebdriver.assert_called_once()
mockNavigateToFilegarden.assert_called_once_with(mockInitializeWebdriver.return_value) mockNavigateToFilegarden.assert_called_once_with(mockInitializeWebdriver.return_value)
mockLoginWithPassword.assert_called_once_with(mockInitializeWebdriver.return_value, mockEmail, mockPassword) mockLoginWithPassword.assert_called_once_with(mockInitializeWebdriver.return_value, mockEmail, mockPassword)
mockClickGoToYourGarden.assert_called_once_with(mockInitializeWebdriver.return_value) mockClickGoToYourGarden.assert_called_once_with(mockInitializeWebdriver.return_value)
mockGetGardenFilenames.assert_called_once_with(mockInitializeWebdriver.return_value) mockGetGardenFilenames.assert_called_once_with(mockInitializeWebdriver.return_value)
mockGetLocalFilenames.assert_called_once_with(mockDirectory)
#mockInitializeWebdriver.return_value.close.assert_called_once() #mockInitializeWebdriver.return_value.close.assert_called_once()