def test_key_type_changed(self): # Change a bitmask key into a simple key self.assert_comparison_result_after_change_equals( "repo.keys[1] = CrmlSimpleKey(ref='Foo.Bar', name='Foo', int='0x2')", modified=[ Entry(sub_id='0x00000002', value_id='key_type', source_value='bitmask_key', target_value='simple_key'), Entry(sub_id='0x00000002', value_id='name', source_value=None, target_value='Foo') ]) # Change a simple key into a bitmask key self.assert_comparison_result_after_change_equals( "repo.keys[0] = CrmlBitmaskKey(int='0x1', name='Foo', bits=[CrmlBit(ref='Foo.Bit1', index=1)])", modified=[ Entry(sub_id='0x00000001', value_id='key_type', source_value='simple_key', target_value='bitmask_key'), Entry(sub_id='0x00000001', value_id='name', source_value=None, target_value='Foo') ])
def check(attrname, old_value, new_value): self.assert_comparison_result_after_change_equals( 'repo.keys[2].subkeys[0].%s = %r' % (attrname, new_value), modified=[ Entry(sub_id='0x10000000-0x1FFFFFFF (sub-key 0x00000001)', value_id=attrname, source_value=old_value, target_value=new_value) ])
def check(attrname, value_id, old_value, new_value): self.assert_comparison_result_after_change_equals( 'repo.keys[1].bits[0].%s = %r' % (attrname, new_value), modified=[ Entry(sub_id='0x00000002 (bit 1)', value_id=value_id, source_value=old_value, target_value=new_value) ])
def test_bitmask_key_bit_changed(self): def check(attrname, value_id, old_value, new_value): self.assert_comparison_result_after_change_equals( 'repo.keys[1].bits[0].%s = %r' % (attrname, new_value), modified=[ Entry(sub_id='0x00000002 (bit 1)', value_id=value_id, source_value=old_value, target_value=new_value) ]) check('ref', 'ref', 'Foo.Bit1', 'Foo.Bar.Bit') check('invert', 'invert', False, True) self.assert_comparison_result_after_change_equals( 'repo.keys[1].bits[0].index = 6', added=[Entry(sub_id='0x00000002 (bit 6)')], removed=[Entry(sub_id='0x00000002 (bit 1)')])
def check(attrname, value_id, old_value, new_value): self.assert_comparison_result_after_change_equals( 'repo.%s = %r' % (attrname, new_value), modified=[ Entry(sub_id=None, value_id=value_id, source_value=old_value, target_value=new_value) ], check_keys_in_entry_data=False)
def test_repository_file_changed(self): self.assert_comparison_result_after_change_equals( '', # Make no modifications in the repository modified=[ Entry(sub_id=None, value_id='file', source_value='test.crml', target_value='xyz.crml') ], target_resource_ref='xyz.crml', check_keys_in_entry_data=False)
def test_key_range_subkey_changed(self): def check(attrname, old_value, new_value): self.assert_comparison_result_after_change_equals( 'repo.keys[2].subkeys[0].%s = %r' % (attrname, new_value), modified=[ Entry(sub_id='0x10000000-0x1FFFFFFF (sub-key 0x00000001)', value_id=attrname, source_value=old_value, target_value=new_value) ]) check('ref', 'Sub1', 'FooSub') check('name', 'Sub-key 1', 'Foo') check('type', 'int', 'real') self.assert_comparison_result_after_change_equals( 'repo.keys[2].subkeys[0].int = "0xA"', added=[Entry(sub_id='0x10000000-0x1FFFFFFF (sub-key 0x0000000A)')], removed=[ Entry(sub_id='0x10000000-0x1FFFFFFF (sub-key 0x00000001)') ])
def test_bitmask_key_changed(self): def check(attrname, value_id, old_value, new_value): self.assert_comparison_result_after_change_equals( 'repo.keys[1].%s = %r' % (attrname, new_value), modified=[ Entry(sub_id='0x00000002', value_id=value_id, source_value=old_value, target_value=new_value) ]) check('name', 'name', None, 'Foobar') check('backup', 'backup', False, True) check('read_only', 'read_only', False, True) check('access.cap_rd', 'cap_rd', None, 'FooCapability') check('access.cap_wr', 'cap_wr', None, 'FooCapability') check('access.sid_rd', 'sid_rd', None, '0x12345678') check('access.sid_wr', 'sid_wr', None, '0x12345678') self.assert_comparison_result_after_change_equals( 'repo.keys[1].int = "0x5"', added=[Entry(sub_id='0x00000005')], removed=[Entry(sub_id='0x00000002')])
def check(attrname, new_value, old_id, new_id): self.assert_comparison_result_after_change_equals( 'repo.keys[2].%s = %r' % (attrname, new_value), added=[Entry(sub_id=new_id)], removed=[Entry(sub_id=old_id)])