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.box = BoxAPI(cls.tempdir) code = authorize_box_user(cls.driver, cls.box.get_auth_url(), BOX_EMAIL, BOX_PASSWD) access_token, refresh_token = cls.box.oauth.authenticate(code) cls.box.write_access_token(access_token, refresh_token) cls.box.build()
class TestBoxAuth(unittest.TestCase): def setUp(self): self.tempdir = create_random_dir() self.box = BoxAPI(self.tempdir) def tearDown(self): delete_dir(self.tempdir) def test_without_credential_file_i_am_not_connected(self): self.assertFalse(self.box.is_connected()) @attr(slow=True) def test_i_can_connect_with_mail_adress_and_password(self): # Given driver = webdriver.Firefox() code = authorize_box_user(driver, self.box.get_auth_url(), BOX_EMAIL, BOX_PASSWD) self.box.oauth.authenticate(code) # When self.box.build() # Then self.assertTrue(self.box.is_connected()) # Clean driver.quit() @attr(slow=True) def test_user_cancel_connection(self): # Given driver = webdriver.Firefox() driver.get(self.box.get_auth_url()) try: enter_text_by_id(driver, "login", BOX_EMAIL, False) enter_text_by_id(driver, "password", BOX_PASSWD) # When click_button_by_id(driver, "consent_reject_button") 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 TestBoxAuth(unittest.TestCase): def setUp(self): self.tempdir = create_random_dir() self.box = BoxAPI(self.tempdir) def tearDown(self): delete_dir(self.tempdir) def test_without_credential_file_i_am_not_connected(self): self.assertFalse(self.box.is_connected()) @attr(slow=True) def test_i_can_connect_with_mail_adress_and_password(self): # Given driver = webdriver.Firefox() code = authorize_box_user(driver, self.box.get_auth_url(), BOX_EMAIL, BOX_PASSWD) self.box.oauth.authenticate(code) # When self.box.build() # Then self.assertTrue(self.box.is_connected()) # Clean driver.quit() @attr(slow=True) def test_user_cancel_connection(self): # Given driver = webdriver.Firefox() driver.get(self.box.get_auth_url()) try: enter_text_by_id(driver, "login", BOX_EMAIL, False) enter_text_by_id(driver, "password", BOX_PASSWD) # When click_button_by_id(driver, "consent_reject_button") 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 box_new = BoxAPI(self.tempdir) # Then self.assertTrue(box_new.is_connected())
def setUp(self): self.tempdir = create_random_dir() self.box = BoxAPI(self.tempdir)