resolve redirects if siteinfo is provided
This commit is contained in:
@@ -262,10 +262,85 @@ class Test_Malformed(unittest.TestCase):
|
||||
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(self.test_output_dir, "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(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(self.test_output_dir, "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(test_file)
|
||||
baseline = pd.read_table(baseline_file)
|
||||
assert_frame_equal(test,baseline, check_like=True)
|
||||
|
||||
|
||||
|
||||
class Test_Stdout(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.wiki = 'sailormoon'
|
||||
self.wiki = 'itwiki'
|
||||
self.wikiq_out_name = self.wiki + ".tsv"
|
||||
|
||||
self.infile = "{0}.xml.7z".format(self.wiki)
|
||||
@@ -287,6 +362,7 @@ class Test_Stdout(unittest.TestCase):
|
||||
test = pd.read_table(StringIO(outs))
|
||||
baseline = pd.read_table(baseline_file)
|
||||
assert_frame_equal(test,baseline, check_like=True)
|
||||
|
||||
|
||||
class Test_Regex(unittest.TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user