-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_core.py
More file actions
49 lines (34 loc) · 1.41 KB
/
test_core.py
File metadata and controls
49 lines (34 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pytest
from hubspot_tech_writing.core import convert, upload
def check_content(html: str):
assert r'<h2 id="about">About' in html
assert r'<a href="https://en.wikipedia.org/wiki/Time_series#Models">time series modeling</a>' in html
def test_convert_file(markdownfile):
html = convert(markdownfile)
check_content(html)
def test_convert_url(markdownurl_https_raw):
html = convert(markdownurl_https_raw)
check_content(html)
def test_convert_io(markdownfile):
fp = open(markdownfile, "r")
html = convert(fp)
check_content(html)
def test_convert_addon_codeblock(markdownfile):
html = convert(markdownfile)
assert (
r'{% module_attribute "code" is_json="true" %}{% raw %}"<pre><code>'
r"from merlion.models.defaults import DefaultDetectorConfig, DefaultDetector\n\n" in html
)
def test_convert_addon_headerlink(markdownfile):
html = convert(markdownfile)
# Verify augmented HTML.
assert (
'<h2 id="about">About <a class="headerlink" href="#about" title="Permalink to heading About">¶</a></h2>' in html
)
# Verify CSS.
assert "a.headerlink {" in html
def test_upload_unknown_file_type(tmp_path):
tmp_file = tmp_path / "foo.txt"
with pytest.raises(ValueError) as ex:
upload(access_token="unknown", source=tmp_file, name="foo", folder_path="/path/to/foo") # noqa: S106
assert ex.match("Unknown file type: .txt")