к
diff --git a/tests/fixtures/pages/image.html b/tests/fixtures/pages/image.html
new file mode 100644
index 0000000..0fabd84
--- /dev/null
+++ b/tests/fixtures/pages/image.html
@@ -0,0 +1 @@
+Схема:
diff --git a/tests/fixtures/pages/links.html b/tests/fixtures/pages/links.html
new file mode 100644
index 0000000..45abe7c
--- /dev/null
+++ b/tests/fixtures/pages/links.html
@@ -0,0 +1,3 @@
+см. раздел абс. +чужой файл чужая +прочее
diff --git a/tests/fixtures/pages/name_quoted.html b/tests/fixtures/pages/name_quoted.html new file mode 100644 index 0000000..fffc285 --- /dev/null +++ b/tests/fixtures/pages/name_quoted.html @@ -0,0 +1 @@ +![]()
', BASE)
+ self.assertEqual((att, links), ([], []))
+
+ def test_page_link_relative(self):
+ _, links = agent.classify_links(page("links.html"), BASE)
+ self.assertEqual(links[0], {"ref": "project/Document/DOC-019834", "code": "DOC-019834"})
+ self.assertEqual(links[1], {"ref": "https://eva.test/project/Document/doc-5", "code": "DOC-5"})
+
+ def test_foreign_host(self):
+ att, links = agent.classify_links(page("links.html"), BASE)
+ self.assertEqual(att, [])
+ self.assertEqual([l["code"] for l in links], ["DOC-019834", "DOC-5"])
+ att, links = agent.classify_links(
+ 'xy',
+ BASE)
+ self.assertEqual((att, links), ([], []))
+
+ def test_name_unquoted(self):
+ att, _ = agent.classify_links(page("name_quoted.html"), BASE)
+ self.assertEqual(att[0]["name"], "ПМП.xlsx")
+ self.assertEqual(att[0]["url"], BASE + OBJ + "/%D0%9F%D0%9C%D0%9F.xlsx")
+
+ def test_ref_exact(self):
+ att, links = agent.classify_links(page("amp.html"), BASE)
+ self.assertEqual(att[0]["ref"], OBJ + "/a.png?version=1&x=2") # после unescape, как ищет хаб
+ self.assertEqual(links[0]["ref"], "project/Document/DOC-7?a=1&b=2")
+ self.assertEqual(att[0]["url"], BASE + OBJ + "/a.png")
+
+ def test_base_with_trailing_slash_and_title(self):
+ att, _ = agent.classify_links('текст' % OBJ, BASE + "/")
+ self.assertEqual(att[0]["name"], "Файл")
+
+ def test_name_from_link_text(self):
+ att, _ = agent.classify_links(' мой файл ' % OBJ, BASE)
+ self.assertEqual(att[0]["name"], "мой файл")
+
+ def test_order_nested_img_in_link(self):
+ att, _ = agent.classify_links(
+ '
' % (OBJ, OBJ, OBJ), BASE)
+ self.assertEqual([a["name"] for a in att], ["a.bin", "b.png", "c.png"])
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_py39.py b/tests/test_py39.py
index 03c76c9..0f95115 100644
--- a/tests/test_py39.py
+++ b/tests/test_py39.py
@@ -18,7 +18,7 @@ class Py39Test(unittest.TestCase):
ast.parse(f.read(), feature_version=(3, 9))
def test_no_third_party_imports(self):
- allowed = {"argparse", "base64", "json", "os", "signal", "ssl", "http", "sys", "time", "urllib", "datetime", "typing", "uuid", "fcntl", "hashlib", "re", "subprocess"}
+ allowed = {"argparse", "base64", "json", "os", "signal", "ssl", "http", "sys", "time", "urllib", "datetime", "typing", "uuid", "fcntl", "hashlib", "re", "html", "subprocess"}
for name in self.FILES:
with self.subTest(name), open(os.path.join(SRC, name), encoding="utf-8") as f:
tree = ast.parse(f.read())