cr-connect-workflow/tests/test_complete_template_scri...

37 lines
1.1 KiB
Python

import json
import os
import unittest
import copy
from docxtpl import Listing
from crc import app
from crc.scripts.complete_template import CompleteTemplate
from tests.base_test import BaseTest
class TestCompleteTemplate(unittest.TestCase):
def test_rich_text_update(self):
script = CompleteTemplate()
data = {"name": "Dan"}
data_copy = copy.deepcopy(data)
script.rich_text_update(data_copy)
self.assertEquals(data, data_copy)
def test_rich_text_update_new_line(self):
script = CompleteTemplate()
data = {"name": "Dan\n Funk"}
data_copy = copy.deepcopy(data)
script.rich_text_update(data_copy)
self.assertNotEqual(data, data_copy)
self.assertIsInstance(data_copy["name"], Listing)
def test_rich_text_nested_new_line(self):
script = CompleteTemplate()
data = {"names": [{"name": "Dan\n Funk"}]}
data_copy = copy.deepcopy(data)
script.rich_text_update(data_copy)
self.assertNotEqual(data, data_copy)
self.assertIsInstance(data_copy["names"][0]["name"], Listing)