| @pytest.mark.asyncio
|
| async def test_create_replace_addition_dicts():
|
|
|
| mock_data = [
|
| {
|
| "type_of_change": "redraft",
|
| "third_party_contract_text": ["This is old text"],
|
| "new_contract_text": ["This is new redrafted text"],
|
| "Commentary": "Redraft due to better wording"
|
| },
|
| {
|
| "type_of_change": "delete",
|
| "third_party_contract_text": ["Delete this clause"],
|
| "new_contract_text": ["(no new text)"],
|
| "Commentary": "This clause is no longer relevant"
|
| },
|
| {
|
| "type_of_change": "add",
|
| "third_party_contract_text": ["This is the text to add after"],
|
| "new_contract_text": ["This is the new added text"],
|
| "Commentary": "Adding new clause"
|
| },
|
| {
|
| "type_of_change": "add",
|
| "third_party_contract_text": ["Another text to add after"],
|
| "new_contract_text": ["Another added text"],
|
| "Commentary": "Adding another clause"
|
| }
|
| ]
|
|
|
| > replace_dict, addition_dict = create_replace_addition_dicts(mock_data)
|
|
|
| test_redline_docx.py:108:
|
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
|
|
| data = [{'Commentary': 'Redraft due to better wording', 'new_contract_text': ['This is new redrafted text'], 'third_party_contract_text': ['This is old text'], 'type_of_change': 'redraft'}, {'Commentary': 'This clause is no longer relevant', 'new_contract_text': ['(no new text)'], 'third_party_contract_text': ['Delete this clause'], 'type_of_change': 'delete'}, {'Commentary': 'Adding new clause', 'new_contract_text': ['This is the new added text'], 'third_party_contract_text': ['This is the text to add after'], 'type_of_change': 'add'}, {'Commentary': 'Adding another clause', 'new_contract_text': ['Another added text'], 'third_party_contract_text': ['Another text to add after'], 'type_of_change': 'add'}]
|
|
|
| def create_replace_addition_dicts(data: List[Any]):
|
| """
|
| The create_replace_addition_dicts function takes in a list of dictionaries, and returns two dictionaries.
|
| The first dictionary is the replace_dict, which contains all the text that needs to be replaced in the contract.
|
| The second dictionary is addition_dict, which contains all the text that needs to be added into the contract.
|
|
|
| :param data:List[Any]: Pass the data from the csv file into this function
|
| :return: A tuple of two dictionaries
|
|
|
| """
|
| replace_dict = {}
|
| addition_dict = []
|
| for ele in data:
|
| > if ele[type_of_change].lower().strip() == "redraft":
|
| E KeyError: 'Type of Change'
|
|
|
| ..\utils\redline_utils\redline_docx.py:229: KeyError
|