def prepareTestList(files, subdir):
    testList = []
    for file in files:
        filePath = os.path.join(subdir, file)
        if (filePath.endswith('.xml')):
            document = ET.parse(filePath)
            root = document.getroot()
            for testcase in root.findall('testcase'):
                name = testcase.attrib['name']
                duration = testcase.attrib['time']
                failure = testcase.find('failure')

                regex = re.compile("([a-zA-Z]+)_([a-zA-Z]+)_([0-9]+)")
                match = regex.match(str(name))
                testId = "_".join(match.groups())
                uid = match.group(3)
                steps = getStepsForTest(testId, subdir)

                if failure is None:
                    test = Test(name, uid, duration, "", steps, False)
                    testList.append(test)
                else:
                    test = Test(name, uid, duration, failure.text[:200], steps,
                                True)
                    testList.append(test)

    return testList
Beispiel #2
0
    def test(self):
        for x in self.urls:
            test = Test()
            print("calling: " + x)
            try:
                r = requests.get(url=x)

                if r.status_code < 300:
                    test.set_message("Success with status code " +
                                     str(r.status_code))
                    test.set_result("Success")
                elif r.status_code < 400:
                    test.set_message("Redirect with status code " +
                                     str(r.status_code))
                    test.set_result("failed")
                elif r.status_code < 500:
                    test.set_message("Bad request with status code " +
                                     str(r.status_code))
                    test.set_result("failed")
                else:
                    test.set_message(
                        "internal server error with status code " +
                        str(r.status_code))
                    test.set_result("failed")
            except requests.exceptions.ConnectionError as e:
                test.set_message("connection failed")
            self.testResults.append(test)
    def runTest(self):
        print("\n############## Running telnet tests ################\n")
        for connection in self.conns:
            test = Test()
            test.set_test_method("Telnet socket connect test")
            ip = connection
            port = self.conns[connection]
            print("\n####### connecting to " + ip + " : " + str(port) +
                  " ########\n")
            try:
                tn = telnetlib.Telnet(ip, port)
                print(tn.read_all())
                test.set_message("Successfully connected to: " + connection +
                                 ":" + conns[connection])
                test.set_result("Success")
                tn.close()

            except TimeoutError as e:
                test.set_message("Failed to connect to: " + connection + ":" +
                                 str(conns[connection]) + " with error \n" +
                                 "Time Out Error error({0}): {1}".format(
                                     e.errno, e.strerror))
                test.set_result("failed")
                print("Time Out Error error({0}): {1}".format(
                    e.errno, e.strerror))
            self.testResults.append(test)
Beispiel #4
0
 def add_test(self):
     from model import Test
     for i in range(3):
         test = Test()
         test.name='fengxin'
         self.session.add(test)
         self.session.commit()
def add_test(input_subject, input_grade, input_picture, input_description,
             input_solution, input_username):
    print("tring to add!!!!!!!!!!!!!!!!!!!!!!!!!")

    test_object = Test(subject=input_subject,
                       grade=input_grade,
                       picture=input_picture,
                       solution=input_solution,
                       username=input_username,
                       description=input_description)
    session.add(test_object)
    session.commit()
Beispiel #6
0
 def runTest(self):
     for connection in self.conns:
         test = Test()
         test.set_test_method("ping")
         resp = ""
         ip = connection
         try:
             op = subprocess.check_output(["ping", ip, "-n", "3"])
             x = str(op)
             y = x.split("\\r\\n")
             for i in y:
                 if not ('b\'' in i) and not ("'" in i):
                     resp += i + "\n"
             test.set_message(resp)
             test.set_result("Success")
             self.testResults.append(test)
         except subprocess.CalledProcessError as e:
             print(e)
             test.set_message("Request failed")
             test.set_result("failed")
             self.testResults.append(test)
Beispiel #7
0
    except:
        pass
    else:
        for pkg in packages:
            pip.main(["install", pkg])
        os.remove(pkgfile)

    from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
    from sklearn.svm import SVC
    from sklearn.tree import DecisionTreeClassifier
    from model import Test
    import warnings

    with warnings.catch_warnings():

        warnings.simplefilter("ignore")

        model = Test(testing_file="labeled")

        model.RandomSelection()
        model.PreBuiltModel(estimator=RandomForestClassifier(n_estimators=35))
        model.PreBuiltModel(estimator=SVC(C=10.0,
                                          gamma=.001,
                                          probability=True,
                                          decision_function_shape="ovr"))
        model.BinaryEnsemble(base_estimator=DecisionTreeClassifier())
        model.BinaryEnsemble(base_estimator=SVC(C=10.0,
                                                gamma=.001,
                                                probability=True,
                                                decision_function_shape="ovr"))