Coverage for test_ghmd.py: 98%
52 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-05 11:04 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-05 11:04 +0000
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3"""
4:Purpose: Testing module for the ``ghmd`` module.
6:Developer: J Berendt
7:Email: development@s3dev.uk
9:Comments: n/a
11# pylint: disable=import-error
12# pylint: disable=invalid-name
13# pylint: disable=wrong-import-order
14"""
16import os
17try:
18 from .base import TestBase
19 from .testlibs.testutils import testutils
20except ImportError:
21 from base import TestBase
22 from testlibs.testutils import testutils
23# The imports for <project> must be after TestBase.
24from ghmdlib import converter
27class TestGHMD(TestBase):
28 """Testing class used to test the ``ghmd`` module."""
30 _ATTN_H = os.path.join(TestBase._DIR_FILES_MD, 'attention-is-all-you-need.html')
31 _ATTN_M = os.path.join(TestBase._DIR_FILES_MD, 'attention-is-all-you-need.md')
32 _DOCL_H = os.path.join(TestBase._DIR_FILES_MD, 'docling-technical-report.html')
33 _DOCL_M = os.path.join(TestBase._DIR_FILES_MD, 'docling-technical-report.md')
34 _LOR1_H = os.path.join(TestBase._DIR_FILES_MD, 'lorem-ipsum-1-tagged-headings.html')
35 _LOR1_M = os.path.join(TestBase._DIR_FILES_MD, 'lorem-ipsum-1-tagged-headings.md')
36 _LOR2_H = os.path.join(TestBase._DIR_FILES_MD, 'lorem-ipsum-2-tagged-headings.html')
37 _LOR2_M = os.path.join(TestBase._DIR_FILES_MD, 'lorem-ipsum-2-tagged-headings.md')
39 @classmethod
40 def setUpClass(cls):
41 """Run this logic at the start of all test cases."""
42 testutils.msgs.startoftest(msg='ghmd')
44 # def setUp(self):
45 # """Run this logic *before* each test case."""
46 # self.disable_terminal_output()
48 # def tearDown(self):
49 # """Run this logic *after* each test case."""
50 # self.enable_terminal_output()
52 def test01a__blackbox(self):
53 """Test the ``ghmdlib`` library as a blackbox.
55 :Test:
56 - Verify the provided Markdown file is converted as expected.
58 """
59 md = self._ATTN_M
60 html = self._ATTN_H
61 exp2 = '38b1855fd00211ea206f30510fca384b'
62 tst1 = converter.convert(path=md,
63 theme='dark',
64 embed_css=False,
65 no_gfm=False,
66 offline=False,
67 preview=False)
68 tst2 = self.get_checksum(path=html, remove_data_run_id=True)
69 self.assertTrue(tst1)
70 self.assertEqual(exp2, tst2)
72 def test01b__blackbox(self):
73 """Test the ``ghmdlib`` library as a blackbox.
75 :Test:
76 - Verify the provided Markdown file is converted as expected.
78 """
79 md = self._DOCL_M
80 html = self._DOCL_H
81 exp2 = '77543a66414aea13a8e4b6f6e4e524f8'
82 tst1 = converter.convert(path=md,
83 theme='dark',
84 embed_css=True, # <-- Changed
85 no_gfm=False,
86 offline=False,
87 preview=False)
88 tst2 = self.get_checksum(path=html, remove_data_run_id=False)
89 self.assertTrue(tst1)
90 self.assertEqual(exp2, tst2)
92 def test01c__blackbox(self):
93 """Test the ``ghmdlib`` library as a blackbox.
95 :Test:
96 - Verify the provided Markdown file is converted as expected.
98 """
99 md = self._LOR1_M
100 html = self._LOR1_H
101 exp2 = '91cf0a0228ac3278ade7129a2b533c95'
102 tst1 = converter.convert(path=md,
103 theme='dark',
104 embed_css=False,
105 no_gfm=True, # <-- Changed
106 offline=False,
107 preview=False)
108 tst2 = self.get_checksum(path=html, remove_data_run_id=False)
109 self.assertTrue(tst1)
110 self.assertEqual(exp2, tst2)
112 def test01d__blackbox(self):
113 """Test the ``ghmdlib`` library as a blackbox.
115 :Test:
116 - Verify the provided Markdown file is converted as expected.
118 """
119 md = self._LOR2_M
120 html = self._LOR2_H
121 exp2 = '33208dd3608e94cd24c5c2fdb491e869'
122 tst1 = converter.convert(path=md,
123 theme='dark',
124 embed_css=False,
125 no_gfm=False,
126 offline=True, # <-- Changed
127 preview=False)
128 tst2 = self.get_checksum(path=html, remove_data_run_id=False)
129 self.assertTrue(tst1)
130 self.assertEqual(exp2, tst2)