Skip to content

Commit

Permalink
tests: verify individual code block theme overrides
Browse files Browse the repository at this point in the history
Signed-off-by: James Knight <james.d.knight@live.com>
  • Loading branch information
jdknight committed Jul 15, 2023
1 parent 85deb3c commit e79d07a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
5 changes: 5 additions & 0 deletions tests/unit-tests/datasets/code-block-theme/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. code-block:: python
:class: confluence-theme-eclipse
import myexample
myexample.invoke()
43 changes: 27 additions & 16 deletions tests/unit-tests/test_sphinx_codeblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,6 @@ def test_storage_sphinx_codeblock_caption(self):
self.assertIsNotNone(title_param)
self.assertEqual(title_param.text, 'code caption test')

@setup_builder('confluence')
def test_storage_sphinx_codeblock_theme(self):
theme = 'Midnight'
config = dict(self.config)
config['confluence_code_block_theme'] = theme
out_dir = self.build(self.dataset, filenames=['code-block'], config=config)

with parse('code-block', out_dir) as data:
theme_params = data.find_all('ac:parameter', {'ac:name': 'theme'})
self.assertIsNotNone(theme_params)
self.assertEqual(len(theme_params), 3)

for theme_param in theme_params:
self.assertIsNotNone(theme_param)
self.assertEqual(theme_param.text, theme)

@setup_builder('confluence')
def test_storage_sphinx_codeblock_default(self):
out_dir = self.build(self.dataset, filenames=['code-block'])
Expand Down Expand Up @@ -117,3 +101,30 @@ def test_storage_sphinx_codeblock_default(self):
# (check at least one code block's content)
self.assertEqual(ruby_block_cdata,
"puts 'this is a print statement!'")

@setup_builder('confluence')
def test_storage_sphinx_codeblock_theme_config(self):
theme = 'Midnight'
config = dict(self.config)
config['confluence_code_block_theme'] = theme
out_dir = self.build(self.dataset, filenames=['code-block'], config=config)

with parse('code-block', out_dir) as data:
theme_params = data.find_all('ac:parameter', {'ac:name': 'theme'})
self.assertIsNotNone(theme_params)
self.assertEqual(len(theme_params), 3)

for theme_param in theme_params:
self.assertIsNotNone(theme_param)
self.assertEqual(theme_param.text, theme)

@setup_builder('confluence')
def test_storage_sphinx_codeblock_theme_override(self):
expected_theme = 'Eclipse'
dataset = os.path.join(self.datasets, 'code-block-theme')
out_dir = self.build(dataset)

with parse('index', out_dir) as data:
code_macro_theme = data.find('ac:parameter', {'ac:name': 'theme'})
self.assertIsNotNone(code_macro_theme)
self.assertEqual(code_macro_theme.text, expected_theme)

0 comments on commit e79d07a

Please sign in to comment.