Exemplo n.º 1
0
        testrun.filter_testcases_by_type(testcases, testcase_type)
    if testcase_type.lower() != 'dvr integration' and module.lower() != 'dvr integration':
        testrun.filter_testcases_by_type(testcases, 'dvr integration', inclusive=False)

    # set testcase list for test run
    testrun.testcases = testcases

    if build is not None:
        # setup test environment
        testrun.setup_test_environment(build, test_name)

        # execute test run
        testrun.run()

        # teardown test environment
        testrun.teardown_test_environment()

    else:
        log.error("Failed to setup test environment. %s is not a valid build." % build)

elif mode == 'webtesting':
    # instance with trace logging and correct db path for Cerberus (web2py) testing
    database = Database(Logger(logging_level='trace'), path=TARTAROS_WEB_DB_PATH)

    # initialize test run object
    testrun = TestRun(log, database, name=test_name, submodule_id=2, results_plan_id=results_plan_id,
                      int_dvr_ip=int_dvr_ip)

    # build testcase list for test run
    testcases = testrun.build_testcase_list_for_run(module_id=module,
        feature_id=feature, story_id=story, test_id=test,
Exemplo n.º 2
0
    def run_test(self, build, test_name, results_plan_id, module=None, feature=None, story=None,
                 test=None, case=None, case_class=None, case_type=None, int_dvr_ip=None,
                 mode=None):
        """ Run test with given parameters.
        """

        operation = inspect.stack()[0][3]
        result = None

        try:
            self.log.trace("%s ..." % operation.replace('_', ' '))

            # instance database for TeamCity testing
            if str(mode).lower() == 'thanatos':
                database = Database(Logger(logging_level='info'), path=getcwdu()+"\\tartaros.sqlite")
                testcase = ThanatosTestCase(self.log, database, case)
                testcase.run()

            else:
                database = Database(Logger(logging_level='info'))

                # initialize test run object
                testrun = TestRun(self.log, database, name=test_name, submodule_id=2,
                                  results_plan_id=results_plan_id, int_dvr_ip=int_dvr_ip)

                # build testcase list for test run
                testcases = testrun.build_testcase_list_for_run(module_id=module,
                    feature_id=feature, story_id=story, test_id=test,
                    case_id=case, case_class=case_class)['testcases']

                # filter by class
                if case_class is not None:
                    testrun.filter_testcases_by_class(testcases, case_class)

                # filter by type
                if case_type is not None:
                    testrun.filter_testcases_by_type(testcases, case_type)

                    if case_type.lower() != 'dvr integration' and str(module) != '9'\
                            and str(module).lower() != 'dvr integration':
                        testrun.filter_testcases_by_type(testcases, 'dvr integration', inclusive=False)

                # set testcase list for test run
                testrun.testcases = testcases

                if str(build).lower() != 'none':
                    # setup test environment
                    testrun.setup_test_environment(build, test_name)
                else:
                    testrun.setup_test_environment(build, test_name, installing=False)

                # execute test run
                testrun.run()

                # teardown test environment
                testrun.teardown_test_environment()

                #else:
                #    self.log.error("Failed to setup test environment. %s is not a valid build." % build)

                # compile results
                result = None

        except BaseException, e:
            self.handle_exception(self.log, e, operation)