4 HCE project, Python bindings, Crawler application. 5 Url normalization tests. 8 @file ftest_UrlNormalization.py 9 @author Alexander Vybornyh <alexander.hce.cluster@gmail.com> 10 @link: http://hierarchical-cluster-engine.com/ 11 @copyright: Copyright © 2017 IOIX Ukraine 12 @license: http://hierarchical-cluster-engine.com/license/ 40 sys.stdout.write(color + str(msg) + bcolors.ENDC + (
'\n' if newLine
else ''))
45 logger = logging.getLogger(
'hce')
46 logger.setLevel(logging.DEBUG)
49 ch = logging.StreamHandler()
50 ch.setLevel(logging.DEBUG)
53 formatter = logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s')
56 ch.setFormatter(formatter)
68 self.
fp = open(fileName,
'w')
78 if self.
fp is not None:
84 result = Utils.urlNormalization(base, url, log=log)
86 printMessage(
"Wrong result: %s\nexpected: %s\n(base: %s, url: %s)" % (result, res, base, url), bcolors.FAIL)
95 pr = argparse.ArgumentParser()
96 pr.add_argument(
'-i',
'--inputFile')
97 pr.add_argument(
'-o',
'--outputFile')
102 if __name__ ==
"__main__":
107 namespace = parser.parse_args(sys.argv[1:])
109 if namespace.inputFile
is None:
110 raise Exception(
"Not set input file name")
114 with open(namespace.inputFile,
'r') as f: 115 lines = f.readlines() 124 elif len(parts) == 2:
127 ofile.write(
'Success: %s\n' % url)
129 ofile.write(
'Fail: %s\n' % url)
131 except Exception, err:
132 sys.stderr.write(str(err) +
'\n')
def __init__(self, fileName)
def executeTest(base, url, res, log=None)
def printMessage(msg, color, newLine=True)