def init_storage_manager(self): self.storage_manager = StorageManager() drive_api = GoogleDriveAPI(demerio_config_dir) self.storage_manager.add_storage("google_drive", drive_api) dropbox = DropboxAPI(demerio_config_dir) self.storage_manager.add_storage("dropbox", dropbox) box = BoxAPI(demerio_config_dir) self.storage_manager.add_storage("box", box)
def setUpClass(cls): cls.driver = webdriver.Firefox() cls.tempdir = create_random_dir() cls.dropbox = DropboxAPI(cls.tempdir) params = authorize_dropbox_user(cls.driver, cls.dropbox.get_auth_url(), DROPBOX_EMAIL, DROPBOX_PASSWD) access_token, user_id, url_state = cls.dropbox.flow.finish(params) cls.dropbox.build(access_token)
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()
def test_i_do_not_need_to_go_through_oauth_if_file_exists(self): # When dropbox_new = DropboxAPI(self.tempdir) # Then self.assertTrue(dropbox_new.is_connected())
def setUp(self): self.tempdir = create_random_dir() self.dropbox = DropboxAPI(self.tempdir)