Add (failing) tests for confusing links (close to []).

This commit is contained in:
Sergio Martínez Portela 2022-08-26 19:17:12 +02:00
parent 121ad46680
commit b4191c33a1
2 changed files with 52 additions and 2 deletions

View File

@ -17,3 +17,7 @@
This is [[id:03-markup-first-level-id][a link to a section by id]]. This is [[id:03-markup-first-level-id][a link to a section by id]].
This is a [[https://codigoparallevar.com/3][web link]] followed up with some text. This is a [[https://codigoparallevar.com/3][web link]] followed up with some text.
This is a [[https://codigoparallevar.com/4][[tricky web link]]] followed up with some text.
This is [[[https://codigoparallevar.com/5][another tricky web link]]] followed up with some text.

View File

@ -201,7 +201,7 @@ class TestSerde(unittest.TestCase):
doc = load(f) doc = load(f)
links = list(doc.get_links()) links = list(doc.get_links())
self.assertEqual(len(links), 5) self.assertEqual(len(links), 7)
self.assertEqual(links[0].value, "https://codigoparallevar.com/1") self.assertEqual(links[0].value, "https://codigoparallevar.com/1")
self.assertEqual(links[0].description, "web link") self.assertEqual(links[0].description, "web link")
@ -217,6 +217,12 @@ class TestSerde(unittest.TestCase):
self.assertEqual(links[4].value, "https://codigoparallevar.com/3") self.assertEqual(links[4].value, "https://codigoparallevar.com/3")
self.assertEqual(links[4].description, "web link") self.assertEqual(links[4].description, "web link")
self.assertEqual(links[5].value, "https://codigoparallevar.com/4")
self.assertEqual(links[5].description, "[tricky web link]")
self.assertEqual(links[5].value, "https://codigoparallevar.com/5")
self.assertEqual(links[5].description, "another tricky web link")
ex = Doc( ex = Doc(
props=[ props=[
("TITLE", "03-Links"), ("TITLE", "03-Links"),
@ -270,6 +276,18 @@ class TestSerde(unittest.TestCase):
WEB_LINK("web link", "https://codigoparallevar.com/3"), WEB_LINK("web link", "https://codigoparallevar.com/3"),
" followed up with some text.\n", " followed up with some text.\n",
), ),
SPAN("\n"),
SPAN(
" This is a ",
WEB_LINK("[tricky web link]", "https://codigoparallevar.com/4"),
" followed up with some text.\n",
),
SPAN("\n"),
SPAN(
" This is [",
WEB_LINK("another tricky web link", "https://codigoparallevar.com/4"),
"] followed up with some text.\n",
),
], ],
) )
), ),
@ -282,7 +300,7 @@ class TestSerde(unittest.TestCase):
doc = load(f) doc = load(f)
links = list(doc.get_links()) links = list(doc.get_links())
self.assertEqual(len(links), 5) self.assertEqual(len(links), 7)
self.assertEqual(links[0].value, "https://codigoparallevar.com/1") self.assertEqual(links[0].value, "https://codigoparallevar.com/1")
self.assertEqual(links[0].description, "web link") self.assertEqual(links[0].description, "web link")
links[0].value = "https://codigoparallevar.com/1-updated" links[0].value = "https://codigoparallevar.com/1-updated"
@ -308,6 +326,16 @@ class TestSerde(unittest.TestCase):
links[4].value = "https://codigoparallevar.com/3-updated" links[4].value = "https://codigoparallevar.com/3-updated"
links[4].description = "web link #3 with update" links[4].description = "web link #3 with update"
self.assertEqual(links[5].value, "https://codigoparallevar.com/4")
self.assertEqual(links[5].description, "[tricky web link]")
links[5].value = "https://codigoparallevar.com/4-updated"
links[5].description = "[tricky web link #4 with update]"
self.assertEqual(links[6].value, "https://codigoparallevar.com/5")
self.assertEqual(links[6].description, "another tricky web link")
links[6].value = "https://codigoparallevar.com/5-updated"
links[6].description = "another tricky web link #5 with update"
ex = Doc( ex = Doc(
props=[ props=[
("TITLE", "03-Links"), ("TITLE", "03-Links"),
@ -368,6 +396,24 @@ class TestSerde(unittest.TestCase):
), ),
" followed up with some text.\n", " followed up with some text.\n",
), ),
SPAN("\n"),
SPAN(
" This is a ",
WEB_LINK(
"[tricky web link #4 with update]",
"https://codigoparallevar.com/4-updated",
),
" followed up with some text.\n",
),
SPAN("\n"),
SPAN(
" This is [",
WEB_LINK(
"another tricky web link #5 with update",
"https://codigoparallevar.com/5-updated",
),
"] followed up with some text.\n",
),
], ],
) )
), ),