Exemple #1
0
class TestDatabaseFieldsInitialization(unittest.TestCase):
    def __init__(self, method_name: str):
        super().__init__(methodName=method_name)
        self.users_table = PlaygroundDynamoDBBasicTable(data_model=TableModel)

    def test_retrieve_multiple_attributes_from_single_object(self):
        """
        Test both the get_field and the get_multiple_fields function
        """

        randomized_item_key = f"key_{uuid4()}"
        random_name = f"name-{uuid4()}"
        random_value = f"value-{uuid4()}"
        timestamp = time()
        randomized_item = {
            'name': random_name,
            'value': random_value,
            'timestamp': timestamp
        }
        query_kwargs = {'itemKey': randomized_item_key}

        set_success: bool = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='multiAttributesContainer.{{itemKey}}',
            query_kwargs=query_kwargs,
            value_to_set=randomized_item)
        self.assertTrue(set_success)

        retrieved_values: dict = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='multiAttributesContainer.{{itemKey}}.(name, value)',
            query_kwargs=query_kwargs)
        self.assertEqual(retrieved_values.get('name'), random_name)
        self.assertEqual(retrieved_values.get('value'), random_value)

        retrieved_values: dict = self.users_table.get_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            getters={
                'one':
                FieldGetter(
                    field_path=
                    'multiAttributesContainer.{{itemKey}}.(name, value)',
                    query_kwargs=query_kwargs)
            })
        self.assertEqual(retrieved_values['one'].get('name', None),
                         random_name)
        self.assertEqual(retrieved_values['one'].get('value', None),
                         random_value)

        deletion_success: bool = self.users_table.delete_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='multiAttributesContainer.{{itemKey}}',
            query_kwargs=query_kwargs)
        self.assertTrue(deletion_success)
class InitializeFieldsWithSharedParents(unittest.TestCase):
    def __init__(self, method_name: str):
        super().__init__(methodName=method_name)
        self.users_table = PlaygroundDynamoDBBasicTable(data_model=TableModel)

    def test_initialize_two_items_with_share_parents(self):
        base_field_path = 'containerForItemsWithSharedParents.{{itemId}}'
        item_name_field_path = f'{base_field_path}.itemName'

        potential_old_data_deletion_success = self.users_table.delete_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            removers={
                'one':
                FieldRemover(field_path=base_field_path,
                             query_kwargs={'itemId': 'itemOne'}),
                'two':
                FieldRemover(field_path=base_field_path,
                             query_kwargs={'itemId': 'itemTwo'})
            })
        # We do not check the success of the deletion operation, because at the time of writing that, if a delete operation try to delete
        # a field path that does not exist, the operation will crash and return a success of False, where what we want is just to make sure
        # the data is fully clean so we can make sure we initialize the items from scratch. We do not really care about removing the data.

        update_success = self.users_table.update_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            setters=[
                FieldSetter(field_path=item_name_field_path,
                            query_kwargs={'itemId': 'itemOne'},
                            value_to_set="NameItemOne"),
                FieldSetter(field_path=item_name_field_path,
                            query_kwargs={'itemId': 'itemTwo'},
                            value_to_set="NameItemTwo"),
            ])
        self.assertTrue(update_success)

        retrieved_items_data = self.users_table.get_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            getters={
                'one':
                FieldGetter(field_path=base_field_path,
                            query_kwargs={'itemId': 'itemOne'}),
                'two':
                FieldGetter(field_path=base_field_path,
                            query_kwargs={'itemId': 'itemTwo'}),
            })
        self.assertIsNotNone(retrieved_items_data)
        self.assertEqual(retrieved_items_data.get('one', None),
                         {'itemName': "NameItemOne"})
        self.assertEqual(retrieved_items_data.get('two', None),
                         {'itemName': "NameItemTwo"})
class TestTableOperations(unittest.TestCase):
    def __init__(self, method_name: str):
        super().__init__(methodName=method_name)
        self.users_table = PlaygroundDynamoDBBasicTable(
            data_model=UsersTableModel)

    def test_get_name_of_one_project(self):
        response_data: Optional[str] = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='projects.{{projectId}}.projectName',
            query_kwargs={'projectId': TEST_PROJECT_ID})
        self.assertIn("test", response_data)

    def test_update_project_name(self):
        success = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='projects.{{projectId}}.projectName',
            query_kwargs={'projectId': TEST_PROJECT_ID},
            value_to_set="test2")
        self.assertTrue(success)

        response_data: Optional[str] = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='projects.{{projectId}}.projectName',
            query_kwargs={'projectId': TEST_PROJECT_ID})
        self.assertEqual(response_data, "test2")

    def test_update_entire_project_model(self):
        success = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='projects.{{projectId}}',
            value_to_set={'projectName': "test3"},
            query_kwargs={'projectId': TEST_PROJECT_ID})

        # todo: allow to set the item of a dict (currently, when doing a query on the projects object,
        #  we will perform an operation of the project map, and not on an individual project item).
        self.assertTrue(success)

        response_data: Optional[str] = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='projects.{{projectId}}.projectName',
            query_kwargs={'projectId': TEST_PROJECT_ID})
        self.assertEqual(response_data, "test3")

    def test_update_entire_project_model_with_missing_project_name(self):
        success = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='projects.{{projectId}}',
            value_to_set={},
            query_kwargs={'projectId': TEST_PROJECT_ID})
        self.assertFalse(success)

    def test_update_entire_project_model_with_invalid_data(self):
        success = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='projects.{{projectId}}',
            value_to_set={'invalidProjectName': "test4"},
            query_kwargs={'projectId': TEST_PROJECT_ID})
        self.assertFalse(success)

        try:
            response_data: Optional[str] = self.users_table.get_field(
                key_value=TEST_ACCOUNT_ID,
                field_path='projects.{{projectId}}.invalidProjectName',
                query_kwargs={'projectId': TEST_PROJECT_ID})
            # If we do not get an error while trying to access an invalid field in the
            # get_field function, then we failed the test.
            self.fail()
        except FieldTargetNotFoundException as e:
            print(e)

    def test_multi_types_field(self):
        success_str: bool = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path="multiTypes",
            value_to_set="yolo")
        self.assertTrue(success_str)

        success_none: bool = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path="multiTypes",
            value_to_set=None)
        self.assertTrue(success_none)

        success_bool: bool = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path="multiTypes",
            value_to_set=True)
        self.assertFalse(success_bool)

    def test_basic_get_multiple_fields_values_in_single_query(self):
        response_data: Optional[dict] = self.users_table.get_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            getters={
                'theAccountId': FieldGetter(field_path='accountId'),
                'theProjects': FieldGetter(field_path='projects')
            })
        self.assertIsNotNone(response_data)
        self.assertEqual(response_data.get('theAccountId', None),
                         TEST_ACCOUNT_ID)

    def test_sophisticated_get_multiple_fields_in_single_query(self):
        response_data: Optional[dict] = self.users_table.get_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            getters={
                'theAccountId':
                FieldGetter(field_path='accountId'),
                'theProjectName':
                FieldGetter(field_path='projects.{{projectId}}.projectName',
                            query_kwargs={'projectId': TEST_PROJECT_ID})
            })
        self.assertIsNotNone(response_data)
        self.assertEqual(response_data.get('theAccountId', None),
                         TEST_ACCOUNT_ID)
        self.assertIn("test", response_data.get('theProjectName', ""))

    def test_basic_update_multiple_fields_in_single_query(self):
        success: bool = self.users_table.update_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            setters=[
                FieldSetter(field_path='number1', value_to_set=42),
                FieldSetter(field_path='string1', value_to_set="Quarante-deux")
            ])
        self.assertTrue(success)

    def test_sophisticated_update_multiple_fields_in_single_query(self):
        success: bool = self.users_table.update_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            setters=[
                FieldSetter(field_path='number1', value_to_set=42),
                FieldSetter(
                    field_path='projects.{{projectId}}.projectName',
                    query_kwargs={'projectId': TEST_PROJECT_ID},
                    value_to_set="test5",
                )
            ])
        self.assertTrue(success)

        project_name_data: Optional[str] = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='projects.{{projectId}}.projectName',
            query_kwargs={'projectId': TEST_PROJECT_ID},
        )
        self.assertEqual(project_name_data, "test5")

    def test_set_and_get_float_in_field_value(self):
        source_float_value = 10.42021023492

        set_float_value_success = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='floatTest',
            value_to_set=source_float_value)
        self.assertTrue(set_float_value_success)

        retrieved_float_value: Optional[float] = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID, field_path='floatTest')
        self.assertEqual(retrieved_float_value, source_float_value)

    def test_remove_basic_item_from_path_target(self):
        success_field_set: bool = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path="fieldToDelete",
            value_to_set="yolo mon ami !")
        self.assertTrue(success_field_set)

        success_field_remove: bool = self.users_table.delete_field(
            key_value=TEST_ACCOUNT_ID, field_path="fieldToDelete")
        self.assertTrue(success_field_remove)

        retrieved_field_data: Optional[float] = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID, field_path="fieldToDelete")
        self.assertIsNone(retrieved_field_data)

    def test_remove_sophisticated_item_from_path_target(self):
        query_kwargs = {"id": "sampleId"}

        success_field_set = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='sophisticatedRemoval.{{id}}.nestedVariable',
            query_kwargs=query_kwargs,
            value_to_set="Soooooo, does it works ? :)")
        self.assertTrue(success_field_set)

        success_field_remove = self.users_table.delete_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='sophisticatedRemoval.{{id}}.nestedVariable',
            query_kwargs=query_kwargs)
        self.assertTrue(success_field_remove)

        retrieved_field_data = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='sophisticatedRemoval.{{id}}.nestedVariable',
            query_kwargs=query_kwargs)
        self.assertIsNone(retrieved_field_data)

    def test_remove_multiple_basic_and_sophisticated_items_from_path_target(
            self):
        query_kwargs = {"id": "sampleIdTwo"}

        success_fields_set: bool = self.users_table.update_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            setters=[
                FieldSetter(
                    field_path='fieldToDelete',
                    value_to_set="multipleBasicAndSophisticatedRemoval"),
                FieldSetter(
                    field_path='sophisticatedRemoval.{{id}}.nestedVariable',
                    query_kwargs=query_kwargs,
                    value_to_set="nestedDude")
            ])
        self.assertTrue(success_fields_set)

        deletion_response = self.users_table.delete_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            removers={
                'field':
                FieldRemover(field_path="fieldToDelete"),
                'nested':
                FieldRemover(
                    field_path="sophisticatedRemoval.{{id}}.nestedVariable",
                    query_kwargs=query_kwargs)
            })
        self.assertTrue(all(deletion_response.values()))

    def test_put_and_delete_records(self):
        success_put_invalid_record = self.users_table.put_record(
            record_dict_data={
                "invalidAccountId": "testAccountId",
                "multiTypes": "testPutRecord"
            })
        self.assertFalse(success_put_invalid_record)

        success_put_valid_record = self.users_table.put_record(
            record_dict_data={
                "accountId": "testAccountId",
                "multiTypes": "testPutRecord"
            })
        self.assertTrue(success_put_valid_record)

        success_delete_record_with_index_typo = self.users_table.delete_record(
            indexes_keys_selectors={"accountIdWithTypo": "testAccountId"})
        self.assertFalse(success_delete_record_with_index_typo)

        success_delete_record_without_typo = self.users_table.delete_record(
            indexes_keys_selectors={"accountId": "testAccountId"})
        self.assertTrue(success_delete_record_without_typo)

    def test_get_value_from_path_target_by_secondary_index(self):
        account_id: Optional[str] = self.users_table.get_field(
            index_name="email",
            key_value=TEST_ACCOUNT_EMAIL,
            field_path="accountId")
        self.assertEqual(account_id, TEST_ACCOUNT_ID)

        account_data: Optional[dict] = self.users_table.get_multiple_fields(
            index_name="email",
            key_value=TEST_ACCOUNT_EMAIL,
            getters={
                "accountId": FieldGetter(field_path="accountId"),
                "username": FieldGetter(field_path="username")
            })
        self.assertEqual(account_data.get("accountId", None), TEST_ACCOUNT_ID)
        self.assertEqual(account_data.get("username", None),
                         TEST_ACCOUNT_USERNAME)

    def test_set_data_inside_a_map_model_field(self):
        dummy_value = str(uuid4())

        set_update_success: bool = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='testMapModel.sampleText',
            value_to_set=dummy_value)
        self.assertEqual(set_update_success, True)

        retrieved_value: Optional[str] = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID, field_path='testMapModel.sampleText')
        self.assertEqual(retrieved_value, dummy_value)

        delete_field_success: bool = self.users_table.delete_field(
            key_value=TEST_ACCOUNT_ID, field_path="testMapModel.sampleText")
        self.assertEqual(delete_field_success, True)

    def test_set_dict_item_with_primitive_value(self):
        success_valid: bool = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='testDictWithPrimitiveValue.{{key}}',
            query_kwargs={'key': "one"},
            value_to_set=True)
        self.assertTrue(success_valid)

        success_invalid: bool = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='testDictWithPrimitiveValue.{{key}}',
            query_kwargs={'key': "one"},
            value_to_set={'keyOfDictThatShouldNotBeHere': True})
        self.assertFalse(success_invalid)
class TestRemoveFieldOperations(unittest.TestCase):
    def __init__(self, method_name: str):
        super().__init__(methodName=method_name)
        self.users_table = PlaygroundDynamoDBBasicTable(data_model=TableModel)

    def test_delete_basic_item_from_path_target(self):
        success_field_set = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='fieldToRemove',
            value_to_set="yolo mon ami !")
        self.assertTrue(success_field_set)

        success_field_remove = self.users_table.delete_field(
            key_value=TEST_ACCOUNT_ID, field_path='fieldToRemove')
        self.assertTrue(success_field_remove)

        retrieved_field_data = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID, field_path='fieldToRemove')
        self.assertIsNone(retrieved_field_data)

    def test_remove_sophisticated_item_from_path_target(self):
        query_kwargs = {'id': 'sampleId'}

        first_message = f"one_{uuid4()}"
        second_message = f"two_{uuid4()}"

        def set_data():
            success_field_set = self.users_table.update_multiple_fields(
                key_value=TEST_ACCOUNT_ID,
                setters=[
                    FieldSetter(
                        field_path=
                        "sophisticatedFieldToRemove.{{id}}.firstNestedValue",
                        query_kwargs=query_kwargs,
                        value_to_set=first_message),
                    FieldSetter(
                        field_path=
                        "sophisticatedFieldToRemove.{{id}}.secondNestedValue",
                        query_kwargs=query_kwargs,
                        value_to_set=second_message)
                ])
            self.assertTrue(success_field_set)

        set_data()

        removed_first_message = self.users_table.remove_field(
            field_path="sophisticatedFieldToRemove.{{id}}.firstNestedValue",
            key_value=TEST_ACCOUNT_ID,
            query_kwargs=query_kwargs,
        )
        self.assertEqual(first_message, removed_first_message)

        removed_second_message = self.users_table.remove_field(
            field_path="sophisticatedFieldToRemove.{{id}}.secondNestedValue",
            key_value=TEST_ACCOUNT_ID,
            query_kwargs=query_kwargs)
        self.assertEqual(second_message, removed_second_message)

        set_data()
        # Since we removed the individuals items, before we can retrieve
        # the entire data, we need to re-set it in the database.
        removed_entire_item = self.users_table.remove_field(
            field_path="sophisticatedFieldToRemove.{{id}}",
            key_value=TEST_ACCOUNT_ID,
            query_kwargs=query_kwargs,
        )
        self.assertEqual(removed_entire_item, {
            'firstNestedValue': first_message,
            'secondNestedValue': second_message
        })
        # Python does not care about the dict ordering when doing a dict comparison

    def test_remove_multiple_fields(self):
        random_id = str(uuid4())
        random_value_one = f"one_{uuid4()}"
        random_value_two = f"two_{uuid4()}"

        update_success = self.users_table.update_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            setters=[
                FieldSetter(field_path='fieldToRemove',
                            value_to_set=random_value_one),
                FieldSetter(
                    field_path=
                    'sophisticatedFieldToRemove.{{id}}.firstNestedValue',
                    query_kwargs={'id': random_id},
                    value_to_set=random_value_two)
            ])
        self.assertTrue(update_success)

        get_response_data = self.users_table.get_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            getters={
                'one':
                FieldGetter(field_path='fieldToRemove'),
                'two':
                FieldGetter(
                    field_path=
                    'sophisticatedFieldToRemove.{{id}}.firstNestedValue',
                    query_kwargs={'id': random_id})
            })
        self.assertEqual(get_response_data.get('one', None), random_value_one)
        self.assertEqual(get_response_data.get('two', None), random_value_two)

        remove_response_data = self.users_table.remove_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            removers={
                'one':
                FieldRemover(field_path='fieldToRemove'),
                'two':
                FieldRemover(
                    field_path=
                    'sophisticatedFieldToRemove.{{id}}.firstNestedValue',
                    query_kwargs={'id': random_id})
            })
        print(remove_response_data)

    def test_remove_multiple_fields_with_multi_selectors(self):
        """
        Removing multiple fields with a multi selector in single field_path in a remove_multiple_fields operation is
        awkward, because a single key per field_path can be assigned. Which means that the multiple fields retrieved
        with the multi selector must be send back in the same dictionary, like if it was a get_field with multi selectors.
        """

        random_id = str(uuid4())
        field_one_random = f"field_one_{uuid4()}"
        field_two_random = f"field_two_{uuid4()}"
        field_three_random = f"field_three_{uuid4()}"

        update_success = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID,
            field_path='sophisticatedFieldToRemove.{{id}}',
            query_kwargs={'id': random_id},
            value_to_set={
                'firstNestedValue': field_one_random,
                'secondNestedValue': field_two_random,
                'thirdNestedValue': field_three_random
            })
        self.assertTrue(update_success)

        get_response_data = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID,
            query_kwargs={'id': random_id},
            field_path=
            'sophisticatedFieldToRemove.{{id}}.(firstNestedValue, secondNestedValue, thirdNestedValue)'
        )
        self.assertEqual(get_response_data.get('firstNestedValue', None),
                         field_one_random)
        self.assertEqual(get_response_data.get('secondNestedValue', None),
                         field_two_random)
        self.assertEqual(get_response_data.get('thirdNestedValue', None),
                         field_three_random)

        remove_response_data = self.users_table.remove_multiple_fields(
            key_value=TEST_ACCOUNT_ID,
            removers={
                'one':
                FieldRemover(
                    field_path=
                    'sophisticatedFieldToRemove.{{id}}.(firstNestedValue, secondNestedValue)',
                    query_kwargs={'id': random_id})
            })
        self.assertEqual(
            remove_response_data.get('one', {}).get('firstNestedValue', None),
            field_one_random)
        self.assertEqual(
            remove_response_data.get('one', {}).get('secondNestedValue', None),
            field_two_random)

        retrieved_third_value = self.users_table.get_field(
            key_value=TEST_ACCOUNT_ID,
            query_kwargs={'id': random_id},
            field_path='sophisticatedFieldToRemove.{{id}}.thirdNestedValue')
        self.assertEqual(retrieved_third_value, field_three_random)
Exemple #5
0
class TestRequestFailsOnFieldsInitializationButRequireExistingFieldsToBeUpdateD(unittest.TestCase):
    """
    This test a rare case, where if the update_multiple_fields is used, and one of the field to update caused the
    request to failed (for example, trying to navigate into an item that does not exist), the library will of course
    try to initialize the missing fields. The library has no idea which field caused the request to fail, so, it will
    try to initialize all of the field, one per one, only if they are not existing. In a single update operation,
    this never cause issues, but in a multi fields update operation, we could have an existing field, that did not
    cause the operation the fail, and that would need to be modify. Yet, since it already exist, the library will not
    correctly modify it as the request instructed it to do. To prevent this issue, if an item already exist the library
    will retrieve its UPDATED_NEW value in the same request (to avoid a get request), and check if the value present in
    the database is the value that our request specified. If its not the case, we will send a new request to modify the
    value. This request will not try to initialize fields if she fails, to avoid potential infinite recursion.
    """

    def __init__(self, method_name: str):
        super().__init__(methodName=method_name)
        self.users_table = PlaygroundDynamoDBBasicTable(data_model=TableModel)

    def test_with_string_value_as_target(self):
        random_id = str(uuid4())
        random_value_one = f"one_{uuid4()}"
        random_value_two = f"two_{uuid4()}"

        initial_update_with_empty_value_success = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID, field_path='fieldAlreadyInitializedRequiringNewValue', value_to_set="initial"
        )
        self.assertTrue(initial_update_with_empty_value_success)

        update_success = self.users_table.update_multiple_fields(key_value=TEST_ACCOUNT_ID, setters=[
            FieldSetter(field_path='fieldAlreadyInitializedRequiringNewValue', value_to_set=random_value_one),
            FieldSetter(
                field_path='containerThatWillFailRequestAndRequireFieldsInitialization.{{id}}.firstNestedValue',
                query_kwargs={'id': random_id}, value_to_set=random_value_two
            )
        ])
        self.assertTrue(update_success)

        get_response_data = self.users_table.get_multiple_fields(key_value=TEST_ACCOUNT_ID, getters={
            'one': FieldGetter(field_path='fieldAlreadyInitializedRequiringNewValue'),
            'two': FieldGetter(field_path='containerThatWillFailRequestAndRequireFieldsInitialization.{{id}}.firstNestedValue', query_kwargs={'id': random_id})
        })
        self.assertEqual(get_response_data.get('one', None), random_value_one)
        self.assertEqual(get_response_data.get('two', None), random_value_two)

    def test_with_dict_values_as_target(self):
        nested_container_field_path = 'containerThatWillFailRequestAndRequireFieldsInitialization.{{id}}.nestedContainer'
        random_first_container_id_one = f"first_container_{uuid4()}"
        random_first_container_id_two = f"second_container_{uuid4()}"
        random_nested_container_id_one = f"id_one_{str(uuid4())}"
        random_nested_container_id_two = f"id_two_{str(uuid4())}"
        random_container_field_value_one = {'secondNestedValue': f"container_field_value_one_{uuid4()}"}
        random_container_field_value_two = {'secondNestedValue': f"container_field_value_two_{uuid4()}"}

        # Initial update that put a single item in the container without risking to override existing fields
        initial_update_with_empty_value_success = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID, field_path=nested_container_field_path + '.{{nestedContainerKey}}',
            query_kwargs={'id': random_first_container_id_one, 'nestedContainerKey': random_nested_container_id_one},
            value_to_set=random_container_field_value_one
        )
        self.assertTrue(initial_update_with_empty_value_success)

        # Multi update operation, that could cause the
        update_success = self.users_table.update_field(
            key_value=TEST_ACCOUNT_ID, field_path=nested_container_field_path + '.{{nestedContainerKey}}',
            query_kwargs={'id': random_first_container_id_two, 'nestedContainerKey': random_nested_container_id_two},
            value_to_set=random_container_field_value_two
        )
        self.assertTrue(update_success)

        retrieved_containers_data = self.users_table.get_multiple_fields(key_value=TEST_ACCOUNT_ID, getters={
            'one': FieldGetter(field_path=nested_container_field_path, query_kwargs={'id': random_first_container_id_one}),
            'two': FieldGetter(field_path=nested_container_field_path, query_kwargs={'id': random_first_container_id_two})
        })
        self.assertEqual(retrieved_containers_data['one'].get(random_nested_container_id_one, None), random_container_field_value_one)
        self.assertEqual(retrieved_containers_data['two'].get(random_nested_container_id_two, None), random_container_field_value_two)