class TestDropboxAuth(unittest.TestCase): def setUp(self): self.tempdir = create_random_dir() self.dropbox = DropboxAPI(self.tempdir) def tearDown(self): delete_dir(self.tempdir) def test_without_credential_file_i_am_not_connected(self): self.assertFalse(self.dropbox.is_connected()) @attr(slow=True) def test_i_can_connect_with_mail_adress_and_password(self): # Given driver = webdriver.Firefox() params = authorize_dropbox_user(driver, self.dropbox.get_auth_url(), DROPBOX_EMAIL, DROPBOX_PASSWD) access_token, user_id, url_state = self.dropbox.flow.finish(params) # When self.dropbox.build(access_token) # Then self.assertTrue(self.dropbox.is_connected()) # Clean driver.quit() @attr(slow=True) def test_user_cancel_connection(self): # Given driver = webdriver.Firefox() driver.get(self.dropbox.get_auth_url()) try: enter_text_by_xpath(driver, "//input[@name='login_email']", DROPBOX_EMAIL, press_return=False) enter_text_by_xpath(driver, "//input[@name='login_password']", DROPBOX_PASSWD) # When click_button_by_name(driver, "deny_access") wait_for_code(driver, "errorPageContainer") except: raise Exception("timeout for authorization") # Then self.assertTrue("error_description" in convert_url_to_query_dict( driver.current_url)) driver.quit()
class TestDropboxAuth(unittest.TestCase): def setUp(self): self.tempdir = create_random_dir() self.dropbox = DropboxAPI(self.tempdir) def tearDown(self): delete_dir(self.tempdir) def test_without_credential_file_i_am_not_connected(self): self.assertFalse(self.dropbox.is_connected()) @attr(slow=True) def test_i_can_connect_with_mail_adress_and_password(self): # Given driver = webdriver.Firefox() params = authorize_dropbox_user(driver, self.dropbox.get_auth_url(), DROPBOX_EMAIL, DROPBOX_PASSWD) access_token, user_id, url_state = self.dropbox.flow.finish(params) # When self.dropbox.build(access_token) # Then self.assertTrue(self.dropbox.is_connected()) # Clean driver.quit() @attr(slow=True) def test_user_cancel_connection(self): # Given driver = webdriver.Firefox() driver.get(self.dropbox.get_auth_url()) try: enter_text_by_xpath(driver, "//input[@name='login_email']", DROPBOX_EMAIL, press_return=False) enter_text_by_xpath(driver, "//input[@name='login_password']", DROPBOX_PASSWD) # When click_button_by_name(driver, "deny_access") wait_for_code(driver, "errorPageContainer") except: raise Exception("timeout for authorization") # Then self.assertTrue("error_description" in convert_url_to_query_dict(driver.current_url)) driver.quit()