Exemple #1
0
    def delete_template(tmpl_id):
        response = requests.delete(f"{BASE_URL}/api/v1/templates/{tmpl_id}")
        log.info(f"delete_template: code: {response} json: {response.json()}")

        log.info(f"delete_template: {response}")

        return response, response.json()
Exemple #2
0
    def get_list_templates() -> Optional[list]:
        response = requests.get(f"{BASE_URL}/api/v1/templates")
        response.raise_for_status()
        response = response.json()

        log.info(f"get_list_templates: {response}")
        return response['templates']
Exemple #3
0
    def get_list_page_elements(self) -> Optional[list]:
        list_page_elements = []

        self.go_to_page()
        list_button = self.elements_by_selector('.form-group')
        if list_button:
            for button in list_button:
                attribute_id = button.find_element_by_css_selector('button').get_attribute('id')
                attribute_label = button.find_element_by_css_selector('button').text
                list_page_elements.append({"id": attribute_id, "label": attribute_label})

        log.info(f"list page elements: {list_page_elements}")
        return list_page_elements
Exemple #4
0
    def elements_by_selector(
            self, selector, delay=DEFAULT_WAITING_ELEMENTS
    ):
        try:
            elems = WebDriverWait(self.browser, delay).until(
                expected_conditions.visibility_of_all_elements_located((By.CSS_SELECTOR, selector))
            )

            log.info(f"Elements by selector {selector} found")
            return elems
        except Exception as e:
            log.info(f"Elements by selector {selector} NOT found {e}")
            return None
Exemple #5
0
    def upload_template(self, generated_list, tmpl_id=None) -> int:
        file = self.yaml_client.write_to_yaml_file(generated_list)
        if tmpl_id is not None:
            payload = {'data': '{"tmpl_id": "%s"}' % tmpl_id}
        else:
            payload = {}

        response = requests.post(f"{BASE_URL}/api/v1/templates",
                                 files=file,
                                 data=payload)
        log.info(f"upload_template: {response.json()}")
        response.raise_for_status()

        return response.json()
Exemple #6
0
    def install_template(tmpl_id):
        response = requests.post(
            f"{BASE_URL}/api/v1/templates/{tmpl_id}/install")
        log.info(f"install_template code: {response} json: {response.json()}")

        return response, response.json()