Пример #1
0
    def determine_test_run_method(self, data):
        """ Determine the method to use.
        @param data: the request data.
        :return: a data dictionary containing
            'successful' - whether the function executed successfully or not.
            'method' - the method to use.
        """

        operation = self.inspect.stack()[0][3]
        result = {'successful': False, 'method': None}

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

            if data is None:
                raise AssertionError("No data received.")

            else:
                # determine by button pressed
                for entry in METHODS.keys():
                    if METHODS[entry]['widget'] in data:
                        result['method'] = METHODS[entry]
                        self.log.trace("Received '%s' command." % result['method']['name'])
                        break

            self.log.trace("... done %s." % operation.replace('_', ' '))
            result['successful'] = True
        except BaseException, e:
            self.handle_exception(e, operation=operation)
Пример #2
0
    def determine_test_run_parameters(self, data, method):
        """ Determine the parameters of the test run.
        @param data: the request data.
        @param method: the method to be executed.
        :return: a data dictionary containing
            'successful' - whether the function executed successfully or not.
            'parameters' - a data dict of all test run parameters.
        """

        operation = self.inspect.stack()[0][3]
        result = {'successful': False,
                  'parameters': {
                      'build': None,
                      'server': None,
                      'testrail plan id': None,
                      'testcases': [],
                  }
        }

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

            if data is None:
                pass

            elif method is None:
                raise AssertionError("No method identified.")

            elif method in METHODS.values():
                self.log.trace("Processing data for '%s' method ..." % method['name'])

                # determine build to test

                # determine testrail plan to publish to

                # determine server to run on
                if data['server'] == '':
                    self.log.trace("No remote server selected. Running test(s) locally ...")
                else:
                    server = RemoteServers.objects.get(pk=data['server'])
                    self.log.trace("%s remote server selected. Running test(s) remotely ..."
                                   % server.name)
                    result['parameters']['server'] = server

                # build testcase list
                self.log.trace("Building list of testcases to run ...")

                if method == METHODS['run full regression test']:
                    testcases = TestCases.objects.all()
                    self.log.trace("Testcases to Run:")
                    for testcase in testcases:
                        self.log.trace_in_line("\n%s:%s" % (testcase.id, testcase.name))
                    result['parameters']['testcases'] = testcases

                #elif method == METHODS['run custom test']:
                    # determine product being tested
                    #if data['product'] == '':

                else:
                    self.log.warn("Failed to build test case list. Invalid method '%s'."
                                  % method['name'])

            else:
                raise AssertionError("Unknown method '%s'." % method['name'])

            self.log.trace("... done %s." % operation.replace('_', ' '))
            result['successful'] = True
        except BaseException, e:
            self.handle_exception(e, operation=operation)