From faf62f39c36c12ebd5ac10e8d5ef8291d6a1e483 Mon Sep 17 00:00:00 2001 From: Arijit Basu Date: Fri, 9 Feb 2024 12:45:19 +0530 Subject: [PATCH] Fix tests --- tests/data/html/audio-is_renderable.html | 2 +- tests/data/html/audio-no_caption.html | 2 +- tests/data/html/audio.html | 2 +- tests/data/html/code_block-is_renderable.html | 2 +- tests/data/html/code_block.html | 2 +- tests/data/html/data_attributes.html | 2 +- tests/data/html/document-is_renderable.html | 2 +- tests/data/html/document-pdf.html | 4 ++-- tests/data/html/document-sketch.html | 4 ++-- tests/data/html/featuredimage-height_width.html | 2 +- tests/data/html/featuredimage-is_renderable.html | 2 +- tests/data/html/featuredimage-mime_type.html | 2 +- tests/data/html/featuredimage-missing_caption.html | 2 +- tests/data/html/featuredimage-no_caption.html | 2 +- tests/data/html/featuredimage.html | 2 +- tests/data/html/heading.html | 2 +- tests/data/html/image-height_width.html | 2 +- tests/data/html/image-is_renderable.html | 2 +- tests/data/html/image-mime_type.html | 2 +- tests/data/html/image-missing_caption.html | 2 +- tests/data/html/image-no_caption.html | 2 +- tests/data/html/image.html | 2 +- tests/data/html/mark_tags.html | 2 +- tests/data/html/ordered_list.html | 2 +- tests/test_transform.py | 14 ++++++++------ tiptapy/__init__.py | 2 +- 26 files changed, 35 insertions(+), 33 deletions(-) diff --git a/tests/data/html/audio-is_renderable.html b/tests/data/html/audio-is_renderable.html index 9ee1d5e..184f0af 100644 --- a/tests/data/html/audio-is_renderable.html +++ b/tests/data/html/audio-is_renderable.html @@ -1 +1 @@ -

Quick brown fox jumps over the lazy dog.

+

Quick brown fox jumps over the lazy dog.

\ No newline at end of file diff --git a/tests/data/html/audio-no_caption.html b/tests/data/html/audio-no_caption.html index 7bd5782..2089158 100644 --- a/tests/data/html/audio-no_caption.html +++ b/tests/data/html/audio-no_caption.html @@ -1,4 +1,4 @@ -
+
diff --git a/tests/data/html/audio.html b/tests/data/html/audio.html index a344dca..10bfd1c 100644 --- a/tests/data/html/audio.html +++ b/tests/data/html/audio.html @@ -1,4 +1,4 @@ -
+
diff --git a/tests/data/html/code_block-is_renderable.html b/tests/data/html/code_block-is_renderable.html index 9ee1d5e..184f0af 100644 --- a/tests/data/html/code_block-is_renderable.html +++ b/tests/data/html/code_block-is_renderable.html @@ -1 +1 @@ -

Quick brown fox jumps over the lazy dog.

+

Quick brown fox jumps over the lazy dog.

\ No newline at end of file diff --git a/tests/data/html/code_block.html b/tests/data/html/code_block.html index 7f121d3..5aea722 100644 --- a/tests/data/html/code_block.html +++ b/tests/data/html/code_block.html @@ -40,4 +40,4 @@ num1 = 54 num2 = 24 -print("The L.C.M. is", compute_lcm(num1, num2))

Readability counts.

Zen of Python By Tom Peters

+print("The L.C.M. is", compute_lcm(num1, num2))

Readability counts.

Zen of Python By Tom Peters

\ No newline at end of file diff --git a/tests/data/html/data_attributes.html b/tests/data/html/data_attributes.html index 96b2849..3f8a132 100644 --- a/tests/data/html/data_attributes.html +++ b/tests/data/html/data_attributes.html @@ -1 +1 @@ -
Sleepy Kitten
Cute Kitty
Happy Kitten
New Kitty
\ No newline at end of file +
Sleepy Kitten
Cute Kitty
Happy Kitten
New Kitty
\ No newline at end of file diff --git a/tests/data/html/document-is_renderable.html b/tests/data/html/document-is_renderable.html index 9ee1d5e..184f0af 100644 --- a/tests/data/html/document-is_renderable.html +++ b/tests/data/html/document-is_renderable.html @@ -1 +1 @@ -

Quick brown fox jumps over the lazy dog.

+

Quick brown fox jumps over the lazy dog.

\ No newline at end of file diff --git a/tests/data/html/document-pdf.html b/tests/data/html/document-pdf.html index 77c3e20..3f5b6fa 100644 --- a/tests/data/html/document-pdf.html +++ b/tests/data/html/document-pdf.html @@ -13,7 +13,7 @@
-
This is pdf caption.

Document Test

+
This is pdf caption.

Document Test

\ No newline at end of file diff --git a/tests/data/html/document-sketch.html b/tests/data/html/document-sketch.html index 8eb2241..a0a9913 100644 --- a/tests/data/html/document-sketch.html +++ b/tests/data/html/document-sketch.html @@ -13,7 +13,7 @@ -
Above URL may result into 404 :)

Document Test

+
Above URL may result into 404 :)

Document Test

\ No newline at end of file diff --git a/tests/data/html/featuredimage-height_width.html b/tests/data/html/featuredimage-height_width.html index 21e14b9..dc801b6 100644 --- a/tests/data/html/featuredimage-height_width.html +++ b/tests/data/html/featuredimage-height_width.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/tests/data/html/featuredimage-is_renderable.html b/tests/data/html/featuredimage-is_renderable.html index 9ee1d5e..184f0af 100644 --- a/tests/data/html/featuredimage-is_renderable.html +++ b/tests/data/html/featuredimage-is_renderable.html @@ -1 +1 @@ -

Quick brown fox jumps over the lazy dog.

+

Quick brown fox jumps over the lazy dog.

\ No newline at end of file diff --git a/tests/data/html/featuredimage-mime_type.html b/tests/data/html/featuredimage-mime_type.html index 9863df0..7729028 100644 --- a/tests/data/html/featuredimage-mime_type.html +++ b/tests/data/html/featuredimage-mime_type.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/tests/data/html/featuredimage-missing_caption.html b/tests/data/html/featuredimage-missing_caption.html index 8422fe7..c9b5d16 100644 --- a/tests/data/html/featuredimage-missing_caption.html +++ b/tests/data/html/featuredimage-missing_caption.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/tests/data/html/featuredimage-no_caption.html b/tests/data/html/featuredimage-no_caption.html index 8422fe7..c9b5d16 100644 --- a/tests/data/html/featuredimage-no_caption.html +++ b/tests/data/html/featuredimage-no_caption.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/tests/data/html/featuredimage.html b/tests/data/html/featuredimage.html index 946f713..eb743a3 100644 --- a/tests/data/html/featuredimage.html +++ b/tests/data/html/featuredimage.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/tests/data/html/heading.html b/tests/data/html/heading.html index 54b327a..e1ef8d9 100644 --- a/tests/data/html/heading.html +++ b/tests/data/html/heading.html @@ -1 +1 @@ -

This is a
word

+

This is a
word

\ No newline at end of file diff --git a/tests/data/html/image-height_width.html b/tests/data/html/image-height_width.html index 0583d79..a458c92 100644 --- a/tests/data/html/image-height_width.html +++ b/tests/data/html/image-height_width.html @@ -1 +1 @@ -
Sleepy Kitten
Cute Kitty
\ No newline at end of file +
Sleepy Kitten
Cute Kitty
\ No newline at end of file diff --git a/tests/data/html/image-is_renderable.html b/tests/data/html/image-is_renderable.html index 9ee1d5e..184f0af 100644 --- a/tests/data/html/image-is_renderable.html +++ b/tests/data/html/image-is_renderable.html @@ -1 +1 @@ -

Quick brown fox jumps over the lazy dog.

+

Quick brown fox jumps over the lazy dog.

\ No newline at end of file diff --git a/tests/data/html/image-mime_type.html b/tests/data/html/image-mime_type.html index 661b14b..5c22f9a 100644 --- a/tests/data/html/image-mime_type.html +++ b/tests/data/html/image-mime_type.html @@ -1 +1 @@ -
python
+
python
\ No newline at end of file diff --git a/tests/data/html/image-missing_caption.html b/tests/data/html/image-missing_caption.html index 17ff431..21d756b 100644 --- a/tests/data/html/image-missing_caption.html +++ b/tests/data/html/image-missing_caption.html @@ -1 +1 @@ -
Sleepy Kitten
+
Sleepy Kitten
\ No newline at end of file diff --git a/tests/data/html/image-no_caption.html b/tests/data/html/image-no_caption.html index 17ff431..21d756b 100644 --- a/tests/data/html/image-no_caption.html +++ b/tests/data/html/image-no_caption.html @@ -1 +1 @@ -
Sleepy Kitten
+
Sleepy Kitten
\ No newline at end of file diff --git a/tests/data/html/image.html b/tests/data/html/image.html index 7bb07f8..36d73b5 100644 --- a/tests/data/html/image.html +++ b/tests/data/html/image.html @@ -1 +1 @@ -
Sleepy Kitten
<script>alert(23)</script>Cute Kitty
+
Sleepy Kitten
<script>alert(23)</script>Cute Kitty
\ No newline at end of file diff --git a/tests/data/html/mark_tags.html b/tests/data/html/mark_tags.html index bce70c6..fae3437 100644 --- a/tests/data/html/mark_tags.html +++ b/tests/data/html/mark_tags.html @@ -1 +1 @@ -

This is bold text, this is italic text, this is <script>alert('hello');</script> italic and bold text and this has a link

\ No newline at end of file +

This is bold text, this is italic text, this is <script>alert('hello');</script> italic and bold text and this has a link

\ No newline at end of file diff --git a/tests/data/html/ordered_list.html b/tests/data/html/ordered_list.html index 0549f97..af4a6d7 100644 --- a/tests/data/html/ordered_list.html +++ b/tests/data/html/ordered_list.html @@ -1 +1 @@ -

Scroll

  1. One

  2. Two

  3. Three

  1. One

  2. Two

  3. Three

+

Scroll

  1. One

  2. Two

  3. Three

  1. One

  2. Two

  3. Three

\ No newline at end of file diff --git a/tests/test_transform.py b/tests/test_transform.py index bccf3a3..d3b3de7 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -1,7 +1,8 @@ import os + import pytest -import tiptapy +import tiptapy tags_to_test = ( "simple", @@ -41,7 +42,7 @@ "document-is_renderable", "document-sketch", "camel-case", - "data_attributes" + "data_attributes", ) @@ -49,6 +50,7 @@ class config: """ Config class to store constans which are used by the othe nodes. """ + DOMAIN = "python.org" @@ -56,15 +58,15 @@ def build_test_data(): """ Scan data directories and return test data """ - store = {'json': {}, 'html': {}} + store = {"json": {}, "html": {}} for data_type in store: - dir_path = os.path.abspath(f'tests/data/{data_type}/') + dir_path = os.path.abspath(f"tests/data/{data_type}/") for file in os.listdir(dir_path): file_path = os.path.join(dir_path, file) with open(file_path) as f: data = f.read() - store[data_type][file.split(f'.{data_type}')[0]] = data - return store['json'], store['html'] + store[data_type][file.split(f".{data_type}")[0]] = data + return store["json"], store["html"] json_data, html_data = build_test_data() diff --git a/tiptapy/__init__.py b/tiptapy/__init__.py index 39f8180..3f3a575 100644 --- a/tiptapy/__init__.py +++ b/tiptapy/__init__.py @@ -33,7 +33,7 @@ def init_env(path, config): env.globals["escape"] = escape env.globals["get_audio_player_block"] = get_audio_player_block env.globals["get_doc_block"] = get_doc_block - env.globals["quote_plus"] = quote_plus + env.filters["quote_plus"] = quote_plus return env