Finish implementing login code
This commit is contained in:
parent
bae05021b7
commit
c4e08faa16
11
jardin.py
11
jardin.py
|
@ -15,8 +15,19 @@ def input_email(browser, email):
|
|||
emailInput.send_keys(email)
|
||||
emailInput.send_keys(Keys.RETURN)
|
||||
|
||||
def click_password_button(browser):
|
||||
passwordButton = browser.find_element(By.XPATH, "/html/body/div[2]/div[3]/div[1]/form/div[1]/span/button[3]")
|
||||
passwordButton.click()
|
||||
|
||||
def input_password(browser, password):
|
||||
passwordInput = browser.find_element(By.ID, "password")
|
||||
passwordInput.send_keys(password)
|
||||
passwordInput.send_keys(Keys.RETURN)
|
||||
|
||||
def login_with_password(browser, email, password):
|
||||
input_email(browser, email)
|
||||
click_password_button(browser)
|
||||
input_password(browser, password)
|
||||
|
||||
def main():
|
||||
with initialize_webdriver() as browser:
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestJardin(unittest.TestCase):
|
|||
mockFirefox.get.assert_called_once_with("https://filegarden.com/login")
|
||||
|
||||
@patch("jardin.webdriver.Firefox")
|
||||
def test_input_email_enters_email_correctly(self, mockFirefox):
|
||||
def test_input_email_enters_email(self, mockFirefox):
|
||||
mockEmail = "email@mail.com"
|
||||
|
||||
jardin.input_email(mockFirefox, mockEmail)
|
||||
|
@ -33,15 +33,38 @@ class TestJardin(unittest.TestCase):
|
|||
call(Keys.RETURN)
|
||||
])
|
||||
|
||||
@patch("jardin.webdriver.Firefox")
|
||||
def test_click_password_button_clicks_button(self, mockFirefox):
|
||||
jardin.click_password_button(mockFirefox)
|
||||
|
||||
mockFirefox.find_element.assert_called_with(By.XPATH, "/html/body/div[2]/div[3]/div[1]/form/div[1]/span/button[3]")
|
||||
mockFirefox.find_element.return_value.click.assert_called_once()
|
||||
|
||||
@patch("jardin.webdriver.Firefox")
|
||||
def test_input_password_enters_password(self, mockFirefox):
|
||||
mockPassword = "p4$$w0rd"
|
||||
|
||||
jardin.input_password(mockFirefox, mockPassword)
|
||||
|
||||
mockFirefox.find_element.assert_called_with(By.ID, "password")
|
||||
mockFirefox.find_element.return_value.send_keys.assert_has_calls([
|
||||
call(mockPassword),
|
||||
call(Keys.RETURN)
|
||||
])
|
||||
|
||||
@patch("jardin.webdriver.Firefox")
|
||||
@patch("jardin.input_email")
|
||||
def test_login_with_password_performs_login_steps(self, mockInputEmail, mockFirefox):
|
||||
@patch("jardin.click_password_button")
|
||||
@patch("jardin.input_password")
|
||||
def test_login_with_password_performs_login_steps(self, mockInputPassword, mockClickPasswordButton, mockInputEmail, mockFirefox):
|
||||
mockEmail = "email@mail.com"
|
||||
mockPassword = "p4$$w0rd"
|
||||
|
||||
jardin.login_with_password(mockFirefox, mockEmail, mockPassword)
|
||||
|
||||
mockInputEmail.assert_called_once_with(mockFirefox, mockEmail)
|
||||
mockClickPasswordButton.assert_called_once_with(mockFirefox)
|
||||
mockInputPassword.assert_called_once_with(mockFirefox, mockPassword)
|
||||
|
||||
@patch("jardin.initialize_webdriver")
|
||||
@patch("jardin.navigate_to_filegarden")
|
||||
|
|
Loading…
Reference in New Issue