From fd77e2075ab143695d4e98bb8074db768fab4209 Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 20 Oct 2023 12:52:58 +0100 Subject: [PATCH] Call login code --- jardin.py | 14 ++++++++------ test_jardin.py | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/jardin.py b/jardin.py index 060da9c..8ce42dc 100755 --- a/jardin.py +++ b/jardin.py @@ -1,5 +1,7 @@ #!/usr/bin/python3 +import sys + from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys @@ -29,15 +31,15 @@ def login_with_password(browser, email, password): click_password_button(browser) input_password(browser, password) -def main(): - with initialize_webdriver() as browser: - navigate_to_filegarden(browser) - # Go To Your Garden - # Log in (email) +def main(email, password): + browser = initialize_webdriver() + navigate_to_filegarden(browser) + login_with_password(browser, email, password) # Go To Your Garden # Get list of filenames in File Garden # 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 + browser.close() if __name__ == "__main__": - main() + main(sys.argv[1], sys.argv[2]) diff --git a/test_jardin.py b/test_jardin.py index 07596f8..8af1579 100755 --- a/test_jardin.py +++ b/test_jardin.py @@ -68,13 +68,21 @@ class TestJardin(unittest.TestCase): @patch("jardin.initialize_webdriver") @patch("jardin.navigate_to_filegarden") + @patch("jardin.login_with_password") def test_main_calls_methods_in_correct_order(self, - mockInitializeWebdriver, - mockNavigateToFilegarden): - jardin.main() + mockLoginWithPassword, + mockNavigateToFilegarden, + mockInitializeWebdriver): + mockEmail = "email@mail.com" + mockPassword = "p4$$w0rd" + + jardin.main(mockEmail, mockPassword) mockInitializeWebdriver.assert_called_once() - mockNavigateToFilegarden.assert_called_once() + mockNavigateToFilegarden.assert_called_once_with(mockInitializeWebdriver.return_value) + mockLoginWithPassword.assert_called_once_with(mockInitializeWebdriver.return_value, mockEmail, mockPassword) + + mockInitializeWebdriver.return_value.close.assert_called_once() if __name__ == "__main__": unittest.main()