errlines = str(errs).split("\\n")
self.assertEqual(errlines[-2],'xml.etree.ElementTree.ParseError: no element found: line 1369, column 0')
+
+class Test_Redirect_Ikwiki(unittest.TestCase):
+ def setUp(self):
+ self.wiki = 'ikwiki-20180301-pages-meta-history'
+ wiki_siteinfo = "ikwiki-20191101-siteinfo-namespaces.json.gz"
+ self.input_dir = "dumps"
+ self.wiki_siteinfo = os.path.join(".", self.input_dir, wiki_siteinfo)
+ self.wikiq_out_name = self.wiki + ".tsv"
+ self.infile = "{0}.xml.bz2".format(self.wiki)
+
+ self.base_call = "../wikiq {0} --siteinfo {1} -o {2}"
+ self.input_dir = "dumps"
+ self.input_file = os.path.join(".", self.input_dir, self.infile)
+ self.baseline_output_dir = "baseline_output"
+
+ self.test_output_dir = os.path.join(".", "test_output")
+ self.call_output = os.path.join(self.test_output_dir, self.wikiq_out_name)
+
+ self.infile = "{0}.xml.bz2".format(self.wiki)
+
+ def test_redirect(self):
+
+ call = self.base_call.format(self.input_file, self.wiki_siteinfo, self.test_output_dir)
+ print(call)
+ proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True)
+ proc.wait()
+
+ test_file = os.path.join("redirect_" + self.wikiq_out_name)
+ copyfile(self.call_output, test_file)
+ baseline_file = os.path.join(".", self.baseline_output_dir, test_file)
+
+ # as a test let's make sure that we get equal data frames
+ test = pd.read_table(os.path.join(self.test_output_dir, test_file))
+
+ baseline = pd.read_table(baseline_file)
+ assert_frame_equal(test,baseline, check_like=True)
+
+
+
+class Test_Redirect_Wikia(unittest.TestCase):
+ def setUp(self):
+ self.wiki = 'pokemonfandomcom_fr-20200215-history'
+ wiki_siteinfo = "pokemonfandomcom_fr-20200215-history.xml.7z"
+ self.input_dir = "dumps"
+ self.wiki_siteinfo = os.path.join(".", self.input_dir, wiki_siteinfo)
+ self.wikiq_out_name = self.wiki + ".tsv"
+ self.infile = "{0}.xml.7z".format(self.wiki)
+
+ self.base_call = "../wikiq {0} --siteinfo {1} -o {2}"
+ self.input_dir = "dumps"
+ self.input_file = os.path.join(".", self.input_dir, self.infile)
+ self.baseline_output_dir = "baseline_output"
+
+ self.test_output_dir = os.path.join(".", "test_output")
+ self.call_output = os.path.join(self.test_output_dir, self.wikiq_out_name)
+
+ self.infile = "{0}.xml.7z".format(self.wiki)
+
+ def test_redirect(self):
+
+ call = self.base_call.format(self.input_file, self.wiki_siteinfo, self.test_output_dir)
+ print(call)
+ proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True)
+ proc.wait()
+
+ test_file = os.path.join("redirect_" + self.wikiq_out_name)
+ copyfile(self.call_output, test_file)
+ baseline_file = os.path.join(".", self.baseline_output_dir, test_file)
+
+ # as a test let's make sure that we get equal data frames
+ test = pd.read_table(os.path.join(self.test_output_dir, test_file))
+ baseline = pd.read_table(baseline_file)
+ assert_frame_equal(test,baseline, check_like=True)
+
+
+
class Test_Stdout(unittest.TestCase):
def setUp(self):
test_file = "noargs_" + self.wikiq_out_name
baseline_file = os.path.join(".", self.baseline_output_dir, test_file)
print(baseline_file)
- test = pd.read_table(StringIO(outs))
+ s = StringIO(outs)
+ test = pd.read_table(s)
baseline = pd.read_table(baseline_file)
assert_frame_equal(test,baseline, check_like=True)
+
class Test_Regex(unittest.TestCase):
def test_regex_inputs(self):
- for input in self.bad_inputs_list:
+ for inpt in self.bad_inputs_list:
call = self.base_call.format(self.input_file)
- call = call + " --stdout " + input
+ call = call + " --stdout " + inpt
print(call)
proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
stdout,stderr = proc.communicate()
self.assertNotEqual(proc.returncode,0)
def test_basic_regex(self):
- for i, input in enumerate(self.good_inputs_list):
+ for i, inpt in enumerate(self.good_inputs_list):
test_filename = "basic_{0}_{1}.tsv".format(self.wikiq_out_name[:-4], str(i))
#print(test_filename)
os.remove(test_file)
call = self.base_call_outs.format(self.input_file, self.test_output_dir)
- call = call + " " + input
+ call = call + " " + inpt
print(call)
proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
def test_capturegroup_regex(self):
- for i, input in enumerate(self.cap_inputs_list):
+ for i, inpt in enumerate(self.cap_inputs_list):
test_filename = "capturegroup_{0}_{1}.tsv".format(self.wikiq_out_name[:-4], str(i))
print(test_filename)
test_file = os.path.join(self.test_output_dir, test_filename)
os.remove(test_file)
call = self.base_call_outs.format(self.input_file, self.test_output_dir)
- call = call + " " + input
+ call = call + " " + inpt
print(call)
proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)