37 lines
1.1 KiB
Python
Executable File
37 lines
1.1 KiB
Python
Executable File
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.assertEqual(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)
|