From 6ad39bcdb22c55cad38080736c90bf1fa2217abf Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Wed, 17 Apr 2024 16:14:48 +0200 Subject: [PATCH] Add unit tests to test id creation in custom content blocks Relates to MS-919 --- server/books/schema/mutations/utils.py | 193 ++++++------ .../tests/test_create_custom_content_block.py | 284 ++++++++++++++++++ .../books/tests/test_custom_content_blocks.py | 145 +++++++++ server/books/tests/test_own_content_blocks.py | 144 --------- 4 files changed, 528 insertions(+), 238 deletions(-) create mode 100644 server/books/tests/test_create_custom_content_block.py create mode 100644 server/books/tests/test_custom_content_blocks.py delete mode 100644 server/books/tests/test_own_content_blocks.py diff --git a/server/books/schema/mutations/utils.py b/server/books/schema/mutations/utils.py index 26d0df40..20e87a1d 100644 --- a/server/books/schema/mutations/utils.py +++ b/server/books/schema/mutations/utils.py @@ -1,15 +1,7 @@ -# -*- coding: utf-8 -*- -# -# Iterativ GmbH -# http://www.iterativ.ch/ -# -# Copyright (c) 2018 Iterativ GmbH. All rights reserved. -# -# Created on 25.09.18 -# @author: Ramon Wenger - import bleach import re +import uuid + from typing import List, Union @@ -33,35 +25,45 @@ def get_previous_item(previous_contents: Union[StreamValue, List[dict]], item: d contents = previous_contents.raw_data else: contents = previous_contents - return next((c for c in contents if c.get('id', None) == item['id']), None) + return next((c for c in contents if c.get("id", None) == item["id"]), None) def handle_text(text): - is_list = bool(re.search(r'