Esempio n. 1
0
 def test_inject_id_to_all_sections_with_label(
     self, app: TestApp, status, warning
 ):  # noqa
     soup = soup_html(app, "with_label.html")
     h2_section = soup.h2.parent
     self.assertIn("id", h2_section.attrs)
     self.assertEqual(h2_section["id"], "override-label")
Esempio n. 2
0
def test_script_tags(app, status, warning):  # noqa
    soup = soup_html(app, "index.html")
    elements = [
        e for e in soup.find_all("script")
        if e.get("src") == "_static/js/test.js"
    ]
    assert len(elements) == 1
 def setUpClass(cls):  # noqa
     cls.app = TestApp(
         srcdir=str(PROJECT_ROOT / "demo/revealjs4"),
         buildername="revealjs",
         copy_srcdir_to_tmpdir=True,
     )
     cls.soup = soup_html(cls.app, "index.html")
Esempio n. 4
0
 def test_script_tags_https(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "index.html")
     elements = [
         e for e in soup.find_all("script")
         if e.get("src") == "https://example.com/test.js"
     ]
     self.assertEqual(len(elements), 1)
Esempio n. 5
0
 def test_revealjs_style_theme(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "index.html")
     links = [
         e for e in soup.find_all("link", rel="stylesheet")
         if "_static/custom.css" in e["href"]
     ]
     self.assertEqual(len(links), 1)
Esempio n. 6
0
 def test_revealjs_script_plugins(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "index.html")
     script = soup.find_all("script")[-1].text
     self.assertIn("plugin_1 = {};", script)
     self.assertIn(
         'plugin_1.src = "_static/revealjs/plugin/highlight/highlight.js"', script
     )
Esempio n. 7
0
 def test_revealjs_css_files(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "index.html")
     links = [
         e for e in soup.find_all("link", rel="stylesheet")
         if "https://example.com/example.css" in e["href"]
     ]
     self.assertEqual(len(links), 1)
Esempio n. 8
0
def test_revealjs_style_theme_custom(app, status, warning):  # noqa
    soup = soup_html(app, "index.html")
    links = [
        e for e in soup.find_all("link", rel="stylesheet")
        if "_static/custom.css" in e["href"]
    ]
    assert len(links) == 1
Esempio n. 9
0
def test_revealjs_script_plugins(app, status, warning):  # noqa
    soup = soup_html(app, "index.html")
    script = str(soup.find_all("script")[-1])
    assert "RevealNotes" in script
    for d in soup.find_all("script"):
        print(d)
    scripts = [d["src"] for d in soup.find_all("script") if "src" in d.attrs]
    assert "_static/revealjs4/plugin/notes/notes.js" in scripts
Esempio n. 10
0
 def test_revealjs_script_plugins(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "index.html")
     script = str(soup.find_all("script")[-1])
     self.assertIn("RevealNotes", script)
     for d in soup.find_all("script"):
         print(d)
     scripts = [d["src"] for d in soup.find_all("script") if "src" in d.attrs]
     self.assertIn("_static/revealjs4/plugin/notes/notes.js", scripts)
Esempio n. 11
0
def test_revealjs_css_files_local(app, status, warning):  # noqa
    soup = soup_html(app, "index.html")
    links = [
        e for e in soup.find_all("link", rel="stylesheet")
        if "_static/custom.css" in e["href"]
    ]
    assert len(links) == 1
    assert (app.outdir / "_static/custom.css").exists()
Esempio n. 12
0
 def test_revealjs_script_plugins(self, app: TestApp, status,
                                  warning):  # noqa
     soup = soup_html(app, "index.html")
     script = soup.find_all("script")[-1].text
     self.assertIn("plugin_0 = {async: true}", script)
     self.assertIn(
         'plugin_0.src = "_static/revealjs/plugin/notes/notes.js"', script)
     self.assertIn("revealjsConfig.dependencies.push(plugin_0);", script)
Esempio n. 13
0
 def test_override_font(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "with_googlefont.html")
     css_hrefs = [
         elm["href"] for elm in soup.find_all("link", rel="stylesheet")
         if elm["href"].startswith("https://fonts.googleapis.com")
     ]
     self.assertEqual(len(css_hrefs), 1)
     styles = "\n".join([str(e) for e in soup.find_all("style")])
     self.assertIn("'M PLUS 1p'", styles)
Esempio n. 14
0
def test_override_font(app, status, warning):  # noqa
    soup = soup_html(app, "with_googlefont.html")
    css_hrefs = [
        elm["href"] for elm in soup.find_all("link", rel="stylesheet")
        if elm["href"].startswith("https://fonts.googleapis.com")
    ]
    assert len(css_hrefs) == 1
    styles = "\n".join([str(e) for e in soup.find_all("style")])
    assert "'M PLUS 1p'" in styles
Esempio n. 15
0
 def test_revealjs_css_files_local(self, app: TestApp, status,
                                   warning):  # noqa
     soup = soup_html(app, "index.html")
     links = [
         e for e in soup.find_all("link", rel="stylesheet")
         if "_static/custom.css" in e["href"]
     ]
     self.assertEqual(len(links), 1)
     self.assertTrue((app.outdir / "_static/custom.css").exists())
Esempio n. 16
0
 def test_default_theme_css_comes_before_custom_css(self, app: TestApp,
                                                    status, warning):
     soup = soup_html(app, "index.html")
     stylesheet_href_list = [
         e["href"] for e in soup.find_all("link", rel="stylesheet")
     ]
     default_theme_index = stylesheet_href_list.index(
         "_static/revealjs4/dist/theme/black.css")
     custom_css_index = stylesheet_href_list.index("_static/custom.css")
     self.assertTrue(default_theme_index < custom_css_index)
Esempio n. 17
0
 def test_google_fonts_with_generic(self, app, status, warning):  # noqa
     soup = soup_html(app, "index.html")
     link = [
         e for e in soup.find_all("link", rel="stylesheet")
         if e["href"].startswith("https://fonts.googleapi")
     ]
     self.assertEqual(len(link), 1)
     style = soup.find_all("style")[-1]
     self.assertIn("Noto Sans JP", style.text)
     self.assertIn("cursive", style.text)
Esempio n. 18
0
def test_priority_html_and_revealjs_js_files(app, status, warning):  # noqa
    soup = soup_html(app, "index.html")
    elm = soup.find(
        "script",
        src="https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.6/dayjs.min.js")
    assert elm is not None
    elm = soup.find(
        "script",
        src="https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.7/dayjs.min.js")
    assert elm is None
Esempio n. 19
0
def test_specified_theme_css_comes_before_custom_css(app, status,
                                                     warning):  # noqa
    soup = soup_html(app, "index.html")
    stylesheet_href_list = [
        e["href"] for e in soup.find_all("link", rel="stylesheet")
    ]
    specified_theme_index = stylesheet_href_list.index(
        "_static/revealjs4/dist/theme/moon.css")
    custom_css_index = stylesheet_href_list.index("_static/other_custom.css")
    assert specified_theme_index < custom_css_index
Esempio n. 20
0
def test_google_fonts_with_generic(app, status, warning):  # noqa
    soup = soup_html(app, "index.html")
    link = [
        e for e in soup.find_all("link", rel="stylesheet")
        if e["href"].startswith("https://fonts.googleapi")
    ]
    assert len(link) == 1
    style = soup.find_all("style")[-1]
    assert "Noto Sans JP" in str(style)
    assert "cursive" in str(style)
Esempio n. 21
0
def test_google_fonts(app, status, warning):  # noqa
    soup = soup_html(app, "index.html")
    link = [
        e for e in soup.find_all("link", rel="stylesheet")
        if e["href"].startswith("https://fonts.googleapis.com/css2")
    ]
    assert len(link) == 1
    style = soup.find_all("style")[-1]
    assert ".reveal" in str(style)
    assert "Noto Sans JP" in str(style)
    assert "sans-serif;" in str(style)
Esempio n. 22
0
 def test_google_fonts(self, app, status, warning):  # noqa
     soup = soup_html(app, "index.html")
     link = [
         e for e in soup.find_all("link", rel="stylesheet")
         if e["href"].startswith("https://fonts.googleapis.com/css2")
     ]
     self.assertEqual(len(link), 1)
     style = soup.find_all("style")[-1]
     self.assertIn(".reveal", str(style))
     self.assertIn("Noto Sans JP", str(style))
     self.assertIn("sans-serif;", str(style))
 def test_config_as_content(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "with_conf_content.html")
     self.assertIn(
         "Object.assign(revealjsConfig, {\n", soup.find_all("script")[-1].text,
     )
     self.assertIn(
         '"transition": "none"\n', soup.find_all("script")[-1].text,
     )
     self.assertIn(
         "});", soup.find_all("script")[-1].text,
     )
Esempio n. 24
0
 def test_render_section2_bg(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "has_section_directive.html")
     section_tag = soup.h2.parent
     self.assertIn("data-background-color", section_tag.attrs)
     self.assertEqual(section_tag["data-background-color"], "#000101")
Esempio n. 25
0
 def test_no_render_parent_bg(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "has_section_directive.html")
     section_tag = soup.h2.parent.parent
     self.assertNotIn("data-background-color", section_tag.attrs)
Esempio n. 26
0
 def test_revealjs_script_conf(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "index.html")
     self.assertIn(
         'Object.assign(revealjsConfig, {transition:"none"});',
         soup.find_all("script")[-1].text,
     )
Esempio n. 27
0
 def test_fragments_generate(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "has_fragments.html")
     self.assertEqual(len(soup.find_all(attrs={"fragment"})), 3)
Esempio n. 28
0
 def test_generic_font_only(self, app, status, warning):  # noqa
     soup = soup_html(app, "index.html")
     styles = soup.find_all("style")
     self.assertEqual(len(styles), 0)
Esempio n. 29
0
 def test_override_theme(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "with_theme.html")
     css_hrefs = [
         elm["href"] for elm in soup.find_all("link", rel="stylesheet")
     ]
     self.assertIn("_static/custom.css", css_hrefs)
Esempio n. 30
0
 def test_config(self, app: TestApp, status, warning):  # noqa
     soup = soup_html(app, "with_conf.html")
     self.assertIn(
         'Object.assign(revealjsConfig, {"transition": "none"});',
         str(soup.find_all("script")[-1]),
     )