Call login code

This commit is contained in:
The Magician 2023-10-20 12:52:58 +01:00
parent c4e08faa16
commit fd77e2075a
2 changed files with 20 additions and 10 deletions

View File

@ -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])

View File

@ -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()