示例#1
0
class CreateWorkspace(unittest.TestCase):
    def setUp(self):
        self.driver = SignIn()

    def test_create_workspace(self):
        driver = self.driver.sign_in()

        with open("../config/aurora_locator.yaml") as f:
            locator = yaml.load(f)
        with open("../config/test_data.yaml") as f:
            test_data = yaml.load(f)

        # create a new workspace
        driver.find_element_by_link_text(locator["workspace_tab_link_text"]).click()
        driver.find_element_by_xpath(locator["workspace_create_xpath"]).click()
        driver.find_element_by_class_name(locator["workspace_name_class_name"]).click()
        driver.find_element_by_class_name(locator["workspace_name_class_name"]).clear()
        driver.find_element_by_class_name(locator["workspace_name_class_name"]).send_keys(test_data["workspace_name"])
        environment_select = Select(driver.find_element_by_class_name(locator["workspace_environment_select_class_name"]))
        environment_select.select_by_visible_text(test_data["workspace_environment"])
        driver.find_element_by_xpath(locator["workspace_save_xpath"]).click()
        workspace_create_check_locator = (By.XPATH, locator["workspace_create_check_xpath"])
        try:
            WebDriverWait(driver, 5, 0.5).until(EC.presence_of_element_located(workspace_create_check_locator))
        except TimeoutException:
            print("create workspace failed")
        else:
            print("create workspace successfully")

    def tearDown(self):
        pass
class CreateDataset(unittest.TestCase):

    def setUp(self):
        self.driver = SignIn()

    def test_create_dataset(self):
        driver = self.driver.sign_in()

        with open("../config/aurora_locator.yaml") as f:
            locator = yaml.load(f)
        with open("../config/test_data.yaml") as f:
            test_data = yaml.load(f)

        # create a new dataset
        driver.find_element_by_link_text(locator["dataset_tab_link_text"]).click()
        driver.find_element_by_link_text(locator["dataset_create_link_text"]).click()
        driver.find_element_by_id(locator["dataset_name_id"]).click()
        driver.find_element_by_id(locator["dataset_name_id"]).clear()
        driver.find_element_by_id(locator["dataset_name_id"]).send_keys(test_data["dataset_name1"])
        driver.find_element_by_id(locator["dataset_default_label_id"]).click()
        driver.find_element_by_id(locator["dataset_default_label_id"]).clear()
        driver.find_element_by_id(locator["dataset_default_label_id"]).send_keys(test_data["dataset_default_label"])
        driver.find_element_by_xpath(locator["dataset_save_xpath"]).click()
        time.sleep(2)

        # upload image1
        driver.find_element_by_xpath(locator["dataset_dropfile"]).send_keys(test_data["dataset_image_1"])
        time.sleep(10)
        # upload image2
        driver.find_element_by_xpath(locator["dataset_upload_button"]).click()
        driver.find_element_by_xpath(locator["dataset_dropfile"]).send_keys(test_data["dataset_image_2"])
        time.sleep(10)

    def tearDown(self):
        pass
class EditDataset(unittest.TestCase):
    def setUp(self):
        self.driver = SignIn()

    def test_edit_dataset(self):
        driver = self.driver.sign_in()

        with open("../config/aurora_locator.yaml") as f:
            locator = yaml.load(f)
        with open("../config/test_data.yaml") as f:
            test_data = yaml.load(f)

        # check if private dataset exists in advance
        driver.find_element_by_link_text(
            locator["dataset_tab_link_text"]).click()
        time.sleep(2)
        try:
            self.assertIsNotNone(
                driver.find_element_by_xpath(locator["dataset_edit_xpath"]))
        except NoSuchElementException:
            print(
                "No private dataset in aurora. Please create a private dataset to run the case."
            )

        # edit dataset:
        # 1. change dataset nanme
        # 2. change private dataset to public dataset
        driver.find_element_by_xpath(locator["dataset_edit_xpath"]).click()
        time.sleep(2)
        current_time = time.strftime("%Y%m%d%H%M%S",
                                     time.localtime(time.time()))
        new_dataset_name = test_data["dataset_name2"] + current_time
        driver.find_element_by_id(locator["dataset_name_id"]).clear()
        driver.find_element_by_id(
            locator["dataset_name_id"]).send_keys(new_dataset_name)
        driver.find_element_by_id(locator["dataset_private_id"]).click()
        driver.find_element_by_xpath(locator["dataset_save_xpath"]).click()
        driver.find_element_by_xpath(
            locator["dataset_sharingcheck_xpath"]).click()
        time.sleep(2)

        # verify the above changes by searching new name in public
        driver.find_element_by_xpath(locator["dataset_public_xpath"]).click()
        time.sleep(2)
        driver.find_element_by_xpath(locator["dataset_search_xpath"]).click()
        driver.find_element_by_xpath(locator["dataset_search_xpath"]).clear()
        driver.find_element_by_xpath(
            locator["dataset_search_xpath"]).send_keys(new_dataset_name)
        try:
            self.assertIsNotNone(
                driver.find_element_by_link_text(new_dataset_name))
        except NoSuchElementException:
            print("Edit dataset failed.")
        else:
            print("Edit dataset successfully.")

    def tearDown(self):
        pass
class EditWorkspace(unittest.TestCase):
    def setUp(self):
        self.driver = SignIn()

    def test_edit_workspace(self):
        driver = self.driver.sign_in()

        with open("../config/aurora_locator.yaml") as f:
            locator = yaml.load(f)
        with open("../config/test_data.yaml") as f:
            test_data = yaml.load(f)

        # go back to workspace page & view the first workspace
        driver.find_element_by_link_text(
            locator["workspace_tab_link_text"]).click()
        time.sleep(2)
        driver.find_element_by_link_text(
            locator["workspace_view_detail_link_text"]).click()
        time.sleep(5)

        # import dataset
        driver.find_element_by_xpath(
            locator["workspace_import_dataset_xpath"]).click()
        first_dataset_locator = (By.XPATH,
                                 locator["workspace_first_dataset_xpath"])
        WebDriverWait(driver, 10, 0.5).until(
            EC.presence_of_element_located(first_dataset_locator))
        dataset_name = driver.find_element_by_xpath(
            locator["workspace_first_dataset_xpath"]).text
        driver.find_element_by_xpath(
            locator["workspace_first_dataset_xpath"]).click()
        driver.find_element_by_xpath(
            locator["workspace_add_button_xpath"]).click()

        add_dataset_check_locator = (By.LINK_TEXT, dataset_name)
        try:
            WebDriverWait(driver, 10, 0.5).until(
                EC.presence_of_element_located(add_dataset_check_locator))
        except TimeoutException:
            print("import dataset failed")
        else:
            print("import dataset successfully")

        # mount volume
        driver.find_element_by_xpath(
            locator["workspace_mount_volume_xpath"]).click()
        driver.find_element_by_xpath(
            locator["workspace_search_volume_xpath"]).send_keys(
                test_data["volume_name"])
        time.sleep(2)
        driver.find_element_by_xpath(
            locator["workspace_first_volume_xpath"]).click()

        #

    def tearDown(self):
        pass
示例#5
0
 def setUp(self):
     self.driver = SignIn()