Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sayanarijit committed Feb 9, 2024
1 parent 1fbd21a commit faf62f3
Show file tree
Hide file tree
Showing 26 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion tests/data/html/audio-is_renderable.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>Quick brown fox jumps over the lazy dog. </p>
<p>Quick brown fox jumps over the lazy dog. </p>
2 changes: 1 addition & 1 deletion tests/data/html/audio-no_caption.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<figure class="audio-player-container"><div><audio src=https://getfoobar/audio/sohtdbcmxu-1581683086.mp3></audio><div class="audio-player audio-player-initialising">
<figure class="audio-player-container"><div><audio src=https%3A%2F%2Fgetfoobar%2Faudio%2Fsohtdbcmxu-1581683086.mp3></audio><div class="audio-player audio-player-initialising">
<div class="player-button">
<i class="icon audio-play-icon"></i>
</div>
Expand Down
2 changes: 1 addition & 1 deletion tests/data/html/audio.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<figure class="audio-player-container"><div><audio src=https://getfoobar/audio/sohtdbcmxu-1581683086.mp3></audio><div class="audio-player audio-player-initialising">
<figure class="audio-player-container"><div><audio src=https%3A%2F%2Fgetfoobar%2Faudio%2Fsohtdbcmxu-1581683086.mp3></audio><div class="audio-player audio-player-initialising">
<div class="player-button">
<i class="icon audio-play-icon"></i>
</div>
Expand Down
2 changes: 1 addition & 1 deletion tests/data/html/code_block-is_renderable.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>Quick brown fox jumps over the lazy dog. </p>
<p>Quick brown fox jumps over the lazy dog. </p>
2 changes: 1 addition & 1 deletion tests/data/html/code_block.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
num1 = 54
num2 = 24

print(&quot;The L.C.M. is&quot;, compute_lcm(num1, num2))</code></pre></div><blockquote><p>Readability counts.</p><p><a href="https://en.wikipedia.org/wiki/Zen_of_Python" target="_blank" rel="noopener nofollow">Zen of Python</a> By <strong>Tom Peters</strong></p></blockquote>
print(&quot;The L.C.M. is&quot;, compute_lcm(num1, num2))</code></pre></div><blockquote><p>Readability counts.</p><p><a href="https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FZen_of_Python" target="_blank" rel="noopener nofollow">Zen of Python</a> By <strong>Tom Peters</strong></p></blockquote>
2 changes: 1 addition & 1 deletion tests/data/html/data_attributes.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div data-show-gap="true" data-type="imageStrip"><figure><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/200/301" type="image"/><img src="https://placekitten.com/200/301" alt="Sleepy Kitten"width="300" height="400"/></picture><figcaption>Cute Kitty</figcaption></figure><figure><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/200/301" type="image"/><img src="https://placekitten.com/200/301" alt="Happy Kitten"width="300" height="400"/></picture><figcaption>New Kitty</figcaption></figure></div>
<div data-show-gap="true" data-type="imageStrip"><figure><picture><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><img src="https%3A%2F%2Fplacekitten.com%2F200%2F301" alt="Sleepy Kitten" width="300" height="400"/></picture><figcaption>Cute Kitty</figcaption></figure><figure><picture><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><img src="https%3A%2F%2Fplacekitten.com%2F200%2F301" alt="Happy Kitten" width="300" height="400"/></picture><figcaption>New Kitty</figcaption></figure></div>
2 changes: 1 addition & 1 deletion tests/data/html/document-is_renderable.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>Quick brown fox jumps over the lazy dog. </p>
<p>Quick brown fox jumps over the lazy dog. </p>
4 changes: 2 additions & 2 deletions tests/data/html/document-pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
</div>
<ul class="file-cta-container">
<li class="download-cta"><a href="http://www.africau.edu/images/default/sample.pdf" target="_blank" rel="noopener noreferrer" download>Download</a></li>
<li class="download-cta"><a href="http%3A%2F%2Fwww.africau.edu%2Fimages%2Fdefault%2Fsample.pdf" target="_blank" rel="noopener noreferrer" download>Download</a></li>
</ul>
</div>
<figcaption>This is pdf caption.</figcaption></figure><p>Document Test</p>
<figcaption>This is pdf caption.</figcaption></figure><p>Document Test</p>
4 changes: 2 additions & 2 deletions tests/data/html/document-sketch.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
</div>
<ul class="file-cta-container">
<li class="download-cta"><a href="http://www.africau.edu/images/default/sample.sketch" target="_blank" rel="noopener noreferrer" download>Download</a></li>
<li class="download-cta"><a href="http%3A%2F%2Fwww.africau.edu%2Fimages%2Fdefault%2Fsample.sketch" target="_blank" rel="noopener noreferrer" download>Download</a></li>
</ul>
</div>
<figcaption>Above URL may result into 404 :)</figcaption></figure><p>Document Test</p>
<figcaption>Above URL may result into 404 :)</figcaption></figure><p>Document Test</p>
2 changes: 1 addition & 1 deletion tests/data/html/featuredimage-height_width.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<figure class="featured-image"><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/200/301" type="image"/><img src="https://placekitten.com/200/301" alt="Sleepy Kitten"width="300" height="400"/></picture><figcaption>Cute Kitty</figcaption></figure>
<figure class="featured-image"><picture><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><img src="https%3A%2F%2Fplacekitten.com%2F200%2F301" alt="Sleepy Kitten" width="300" height="400"/></picture><figcaption>Cute Kitty</figcaption></figure>
2 changes: 1 addition & 1 deletion tests/data/html/featuredimage-is_renderable.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>Quick brown fox jumps over the lazy dog. </p>
<p>Quick brown fox jumps over the lazy dog. </p>
2 changes: 1 addition & 1 deletion tests/data/html/featuredimage-mime_type.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<figure class="featured-image"><picture><source srcset="https://www.python.org/python-logo.webp" type="image/webp"/><source srcset="https://www.python.org/python-logo.png" type="image/png"/><img src="https://www.python.org/python-logo.png" alt="python"/></picture></figure>
<figure class="featured-image"><picture><source srcset="https%3A%2F%2Fwww.python.org%2Fpython-logo.webp" type="image/webp"/><source srcset="https%3A%2F%2Fwww.python.org%2Fpython-logo.png" type="image/png"/><img src="https%3A%2F%2Fwww.python.org%2Fpython-logo.png" alt="python"/></picture></figure>
2 changes: 1 addition & 1 deletion tests/data/html/featuredimage-missing_caption.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<figure class="featured-image"><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/198/654" type="image"/><img src="https://placekitten.com/198/654" alt="Brown Kitten Image"/></picture></figure>
<figure class="featured-image"><picture><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><source srcset="https%3A%2F%2Fplacekitten.com%2F198%2F654" type="image"/><img src="https%3A%2F%2Fplacekitten.com%2F198%2F654" alt="Brown Kitten Image"/></picture></figure>
2 changes: 1 addition & 1 deletion tests/data/html/featuredimage-no_caption.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<figure class="featured-image"><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/198/654" type="image"/><img src="https://placekitten.com/198/654" alt="Brown Kitten Image"/></picture></figure>
<figure class="featured-image"><picture><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><source srcset="https%3A%2F%2Fplacekitten.com%2F198%2F654" type="image"/><img src="https%3A%2F%2Fplacekitten.com%2F198%2F654" alt="Brown Kitten Image"/></picture></figure>
2 changes: 1 addition & 1 deletion tests/data/html/featuredimage.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<figure class="featured-image"><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/198/654" type="image"/><img src="https://placekitten.com/198/654" alt="Brown Kitten Image"/></picture><figcaption>Cute Kitty</figcaption></figure>
<figure class="featured-image"><picture><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><source srcset="https%3A%2F%2Fplacekitten.com%2F198%2F654" type="image"/><img src="https%3A%2F%2Fplacekitten.com%2F198%2F654" alt="Brown Kitten Image"/></picture><figcaption>Cute Kitty</figcaption></figure>
2 changes: 1 addition & 1 deletion tests/data/html/heading.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h2><strong>This</strong> is a <br><em>word</em></h2>
<h2><strong>This</strong> is a <br><em>word</em></h2>
2 changes: 1 addition & 1 deletion tests/data/html/image-height_width.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<figure><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/200/301" type="image"/><img src="https://placekitten.com/200/301" alt="Sleepy Kitten"width="300" height="400"/></picture><figcaption>Cute Kitty</figcaption></figure>
<figure><picture><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><img src="https%3A%2F%2Fplacekitten.com%2F200%2F301" alt="Sleepy Kitten" width="300" height="400"/></picture><figcaption>Cute Kitty</figcaption></figure>
2 changes: 1 addition & 1 deletion tests/data/html/image-is_renderable.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>Quick brown fox jumps over the lazy dog. </p>
<p>Quick brown fox jumps over the lazy dog. </p>
2 changes: 1 addition & 1 deletion tests/data/html/image-mime_type.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<figure><picture><source srcset="https://www.python.org/python-logo.webp" type="image/webp"/><source srcset="https://www.python.org/python-logo.png" type="image/png"/><img src="https://www.python.org/python-logo.png" alt="python"/></picture></figure>
<figure><picture><source srcset="https%3A%2F%2Fwww.python.org%2Fpython-logo.webp" type="image/webp"/><source srcset="https%3A%2F%2Fwww.python.org%2Fpython-logo.png" type="image/png"/><img src="https%3A%2F%2Fwww.python.org%2Fpython-logo.png" alt="python"/></picture></figure>
2 changes: 1 addition & 1 deletion tests/data/html/image-missing_caption.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<figure><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/198/654" type="image"/><img src="https://placekitten.com/198/654" alt="Sleepy Kitten"/></picture></figure>
<figure><picture><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><source srcset="https%3A%2F%2Fplacekitten.com%2F198%2F654" type="image"/><img src="https%3A%2F%2Fplacekitten.com%2F198%2F654" alt="Sleepy Kitten"/></picture></figure>
2 changes: 1 addition & 1 deletion tests/data/html/image-no_caption.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<figure><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/198/654" type="image"/><img src="https://placekitten.com/198/654" alt="Sleepy Kitten"/></picture></figure>
<figure><picture><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><source srcset="https%3A%2F%2Fplacekitten.com%2F198%2F654" type="image"/><img src="https%3A%2F%2Fplacekitten.com%2F198%2F654" alt="Sleepy Kitten"/></picture></figure>
2 changes: 1 addition & 1 deletion tests/data/html/image.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<figure><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/198/654" type="image"/><img src="https://placekitten.com/198/654" alt="Sleepy Kitten"/></picture><figcaption>&lt;script&gt;alert(23)&lt;/script&gt;Cute Kitty</figcaption></figure>
<figure><picture><source srcset="https%3A%2F%2Fplacekitten.com%2F200%2F301" type="image"/><source srcset="https%3A%2F%2Fplacekitten.com%2F198%2F654" type="image"/><img src="https%3A%2F%2Fplacekitten.com%2F198%2F654" alt="Sleepy Kitten"/></picture><figcaption>&lt;script&gt;alert(23)&lt;/script&gt;Cute Kitty</figcaption></figure>
2 changes: 1 addition & 1 deletion tests/data/html/mark_tags.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>This is <strong>bold text</strong>, this is <em>italic text</em>, this is <strong><em>&lt;script&gt;alert(&#x27;hello&#x27;);&lt;/script&gt; italic and bold text</em></strong> and this has a <a href="https://foobar.withgoogle.com/" title="foo.bar" target="_blank" rel="noopener nofollow">link</a></p>
<p>This is <strong>bold text</strong>, this is <em>italic text</em>, this is <strong><em>&lt;script&gt;alert(&#x27;hello&#x27;);&lt;/script&gt; italic and bold text</em></strong> and this has a <a title="foo.bar" href="https%3A%2F%2Ffoobar.withgoogle.com%2F" target="_blank" rel="noopener nofollow">link</a></p>
2 changes: 1 addition & 1 deletion tests/data/html/ordered_list.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h1>Scroll</h1><ol start="1"><li><p>One</p></li><li><p>Two</p></li><li><p>Three</p></li></ol><ol start="2"><li><p>One</p></li><li><p>Two</p></li><li><p>Three</p></li></ol>
<h1>Scroll</h1><ol start="1"><li><p>One</p></li><li><p>Two</p></li><li><p>Three</p></li></ol><ol start="2"><li><p>One</p></li><li><p>Two</p></li><li><p>Three</p></li></ol>
14 changes: 8 additions & 6 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os

import pytest
import tiptapy

import tiptapy

tags_to_test = (
"simple",
Expand Down Expand Up @@ -41,30 +42,31 @@
"document-is_renderable",
"document-sketch",
"camel-case",
"data_attributes"
"data_attributes",
)


class config:
"""
Config class to store constans which are used by the othe nodes.
"""

DOMAIN = "python.org"


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()
Expand Down
2 changes: 1 addition & 1 deletion tiptapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit faf62f3

Please sign in to comment.