import importlib.util
import pathlib
import unittest


ROOT = pathlib.Path(__file__).resolve().parents[1]
MODULE_PATH = ROOT / 'scripts' / 'render_body.py'

spec = importlib.util.spec_from_file_location('render_body', MODULE_PATH)
render_body = importlib.util.module_from_spec(spec)
spec.loader.exec_module(render_body)


class RenderBodyContentFormatTests(unittest.TestCase):
    def test_normalize_accepts_blocks_key(self):
        block = {'type': 'body', 'text': 'hello'}
        data = {'title': 'x', 'blocks': [block]}
        self.assertEqual(render_body._normalize_content_blocks(data), [block])

    def test_normalize_accepts_content_key(self):
        block = {'type': 'body', 'text': 'hello'}
        data = {'title': 'x', 'content': [block]}
        self.assertEqual(render_body._normalize_content_blocks(data), [block])


if __name__ == '__main__':
    unittest.main()
