Example #1
0
 def testInit(self):
     query = "python:math:how to use sine"
     con = cont.ControlManager(query)
     self.assertEqual(con.query, query)
     self.assertEqual(con.filterObject, None)
     self.assertEqual(con.crawlerObject, None)
     self.assertIs(type(con.fileHandler), fsh.FileSystemHandler)
Example #2
0
 def testExecuteFiltering(self):
     query = "python:math:how to use sine"
     con = cont.ControlManager(query)
     con.initSession()
     con.crawlQuery()
     result = con.executeFiltering()
     self.assertTrue("sin(x)" in result)
Example #3
0
 def testCloseSession(self):
     query = "python:math:how to use sine"
     con = cont.ControlManager(query)
     con.initSession()
     con.crawlQuery()
     result = con.executeFiltering()
     con.closeSession()
     rootDir = con.fileHandler.getRootDirectory()
     self.assertTrue(
         os.path.exists(rootDir) and os.path.isdir(rootDir)
         and not os.listdir(rootDir))
Example #4
0
 def testCrawlQuery(self):
     query = "python:math:how to use sine"
     con = cont.ControlManager(query)
     con.initSession()
     con.crawlQuery()
     self.assertTrue(con.fileHandler.getSearchFilePath(
         "python", "math.txt"))
     fileTest = open(con.fileHandler.getSearchFilePath(
         "python", "math.txt")).read()
     self.assertTrue("sin" in fileTest and "cos" in fileTest
                     and "<html>" not in fileTest)
Example #5
0
    return data


def compareCSVFfiles(csvA, csvB):
    compareResults = dict()
    assert len(csvA) == len(csvB)
    for key in csvA.keys():
        if newLineRemover(csvA[key]) == newLineRemover(csvB[key]):
            compareResults[key] = "True"
        else:
            compareResults[key] = "False"
    return compareResults


if __name__ == "__main__":
    results, testDir = dict(), os.getcwd() + getSlashForOsVersion(
    ) + "testDataForAccuracy" + getSlashForOsVersion()

    testData = open(testDir + "testQueries.txt").readlines()
    for query in testData:
        c = con.ControlManager(query)
        c.initSession()
        c.crawlQuery()
        results[query] = c.executeFiltering()

    saveCSVFile(testDir + "testResults.csv", results, "Query;Result")
    perfectResults = loadCSVFile(testDir + "testResults.csv")
    saveCSVFile(testDir + "compareResults.csv",
                compareCSVFfiles(perfectResults, perfectResults),
                "Query;testResults == intendedResult")
Example #6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import py_files.controller as con

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("ERROR: argument missing")
    else:
        c = con.ControlManager(sys.argv[1])
        c.initSession()
        c.crawlQuery()
        result = c.executeFiltering()
        #c.closeSession()
        print(result)
Example #7
0
 def sendClientDataToControlClass(self):
     self.CONT = cont.ControlManager(pickle.loads(self.DATA))
     self.CONT.initSession()
     self.CONT.crawlQuery()
     self.DATA = pickle.dumps(self.CONT.executeFiltering())
     self.CONT.closeSession()
Example #8
0
 def testInitSession(self):
     query = "python:math:how to use sine"
     con = cont.ControlManager(query)
     con.initSession()
     self.assertTrue(os.path.isdir(con.fileHandler.getRootDirectory()))