示例#1
0
文件: test_data.py 项目: jcflow/comma
    def test_modify_record_by_name(self, table_info: CommaTableTestingExtrasType):
        """
        Checks to see if modifications to a `CommaTable` object are correctly
        propagated where expected, when fields are edited by key (dict access).
        """
        with extradict.MapGetter(table_info) as info:
            from info import table, record_index, field_index, field_name
            from info import some_record, some_record_copy

            some_record[field_name] = self.SOME_STRING

            # has the original record been modified?
            self.assert_record_has_changed(
                table_info=table_info,
                modified_string=self.SOME_STRING,
            )
示例#2
0
文件: test_data.py 项目: jcflow/comma
    def test_modify_record_field_slicing(self, table_info: CommaTableTestingExtrasType):
        """
        Checks to see if modifications to a `CommaTable` object are correctly
        propagated where expected, when fields are edited by key (dict access).
        """
        with extradict.MapGetter(table_info) as info:
            from info import table, record_index, field_index, field_name
            from info import some_record, some_record_copy

            # TEST: CAN EDITING BY FIELD SLICING PROPAGATE MODIFICATIONS
            table[field_name][record_index] = self.SOME_STRING

            # has the original record been modified?
            self.assert_record_has_changed(
                table_info=table_info,
                modified_string=self.SOME_STRING,
            )
示例#3
0
文件: test_data.py 项目: jcflow/comma
    def assert_record_unmodified(
            table_info: CommaTableTestingExtrasType,
    ):
        with extradict.MapGetter(table_info) as info:
            from info import table, record_index, field_index, original_value
            from info import some_record, some_record_copy

            # integrity: is the isolated record consistent with main record?
            assert table[record_index][field_index] == some_record[field_index]

            # check whether all accesses to this record produce the same value
            if string is not None:
                assert table[record_index][field_index] == original_value
                assert record[field_index] == string
                assert some_record_copy[field_index] == original_value

            # is the same as the copy? (the above may succeed and below fail,
            # but not the opposite; i.e. below is strictly stronger than above,
            # but test is intended to be granular)
            assert dict(some_record) == dict(some_record_copy)
            assert dict(table[record_index]) == dict(some_record)
            assert dict(table[record_index]) == dict(some_record_copy)
示例#4
0
文件: test_data.py 项目: jcflow/comma
    def assert_record_has_changed(
            table_info: CommaTableTestingExtrasType,
            modified_string: typing.Optional[str] = None,
    ):
        with extradict.MapGetter(table_info) as info:
            from info import table, record_index, field_index, original_value
            from info import some_record, some_record_copy

            # integrity: is the isolated record consistent with main record?
            assert table[record_index][field_index] == some_record[field_index]

            # correctness: has the isolated record been modified?
            if modified_string is not None:
                assert table[record_index][field_index] == modified_string

            # does it differ from the copy?
            assert dict(some_record) != dict(some_record_copy)
            assert dict(table[record_index]) != dict(some_record_copy)

            # check if copy still has original value
            if original_value is not None:
                assert some_record_copy[field_index] == original_value