def test_get_a_special_chars_mixed(self): """Put anchor containing all special and wildcard characters""" testdb = DB(SQLiteRepo()) chardict = testdb.get_special_chars() suffix = "".join((chardict["E"], chardict["F"], chardict["WC"])) data = [("".join((x, suffix)), -10) for x in chardict["PX"]] testdb.import_data(data) for d in data: samp = list(testdb.export()) self.assertEqual(samp, data)
def test_put_a_special_chars_mixed(self): """Put anchor containing all special characters. Characters must come out the same way they went in. """ testdb = DB(SQLiteRepo()) fi = lambda x, y: "".join((escape(x), y)) chardict = testdb.get_special_chars() suffix = "".join((chardict["E"], chardict["F"], chardict["WC"])) data = [("".join((p, suffix)), -10) for p in chardict["PX"]] for d in data: testdb.put_a(*d) samp = list(testdb.export()) self.assertEqual(samp, data)
def test_get_a_special_chars_prefix(self): """Get anchors containing escaped prefix special chars Only the first char needs to be escaped """ testdb = DB(SQLiteRepo()) px_chars = testdb.get_special_chars()["PX"] fi = lambda x: "{}uuu{}u".format(escape(x), x) # format input fo = lambda x: "{0}uuu{0}u".format(x) # format output data = [(fi(x), None) for x in px_chars] testdb.import_data(data) for c in px_chars: samp = next(testdb.get_a(fi(c), out_format='interchange')) expected = (fo(c), None) self.assertEqual(samp, expected)