Beispiel #1
0
 def tc_001_topic_title_test(self, topic):
     preporter.info("Opening URL: " + config.BASE_URL)
     self._driver.open_url(config.BASE_URL)
     self._home_page.navigate_to_help_tab()
     self._home_page.click_to_community_link()
     self._driver.switch_window()
     preporter.info("Searching for " + topic)
     self._community_page.search_text(topic)
     self._community_page.find_and_click_topic_from_search_results(topic)
     try:
         assert_equals(self._community_page.get_topic_title(), topic, "Expected topic title not proper")
         self._driver.close_tab()
     except AssertionError:
         self._driver.close_tab()
         fail("Expected topic title not proper")
Beispiel #2
0
 def tc_002_topic_search_perfect_match_test(self, announcement):
     preporter.info("Opening URL: " + config.BASE_URL)
     self._driver.open_url(config.BASE_URL)
     self._home_page.navigate_to_help_tab()
     self._home_page.click_to_community_link()
     self._driver.switch_window()
     preporter.info("Searching for " + announcement)
     self._community_page.search_text(announcement)
     try:
         assert_equals(self._community_page.get_first_order_search_results_titles()[0], announcement,
                       "Item is not in top of search results")
         self._driver.close_tab()
     except AssertionError:
         self._driver.close_tab()
         fail("Item is not in top of search results")
Beispiel #3
0
    def on_test_case_start(self, test_case):
        if self.is_dependent_test_case(test_case):
            if self.is_parent_test_passed(test_case):
                preporter.info(
                    "Parent test {} has passed. Starting execution of current test case."
                    .format(self.get_parent_test_case_name(test_case)))

            elif self.is_parent_test_failed(test_case):
                preporter.warn(
                    "Parent test {} has failed. Current test case will be skipped."
                    .format(self.get_parent_test_case_name(test_case)))
                self.add_skipped_test(test_case)
                fail("Skipping test case as parent test failed.")

            elif self.is_parent_test_skipped(test_case):
                preporter.warn(
                    "Parent test {} has been skipped. Current test case will be skipped."
                    .format(self.get_parent_test_case_name(test_case)))
                self.add_skipped_test(test_case)
                fail("Skipping test case as parent test has been skipped.")

            else:
                preporter.critical(
                    "Parent test {} has not been executed! Please check naming convention of test cases "
                    "and ensure parent test is executed first.".format(
                        self.get_parent_test_case_name(test_case)))
                self.add_skipped_test(test_case)
                fail(
                    "Skipping test case as parent test has NOT been executed yet."
                )
        else:
            preporter.info("Starting execution of current test case.")
def request(url,
            method,
            json_data=None,
            session=None,
            headers=None,
            assertion=None):
    data = ''
    status_code = ''
    req_json = ''
    try:
        text = session.request(url=url,
                               method=method,
                               json=json_data,
                               headers=headers).text
        if len(text) <= 1000:
            preporter.info(text)
        req_json = json.loads(text)
        status_code = req_json["status"]
        data = req_json["data"]
        preporter.info('接口返回status为:' + str(status_code))
        if len(str(data)) >= 3000:
            preporter.info('接口返回data为(限制长度为3000):' + str(data)[0:3000])
        else:
            preporter.info('接口返回data为:' + str(data))
    except BaseException:
        if not assertion:
            fail('无法获取status或data!')
        else:
            key = assertion.keys()
            assert_equals(assertion[key], req_json[key])
    finally:
        if not assertion:
            if not status_code == 'ok':
                preporter.error('接口响应:' + str(req_json))
            else:
                assert_equals(status_code, 'ok')
            assert_equals(status_code, 'ok')
        if data is not None:
            return data
Beispiel #5
0
 def test3(self):
     fail("failed")