def test_modified_info_dict(self): re = Resource(self.client, DefaultManager(self.client)) self.assertEqual(re._get_modified_info_dict(), {}) re._set_modified_info_dict('key1', 'val1') self.assertEqual(re._get_modified_info_dict(), {'key1': 'val1'}) re._del_modified_info_dict_key('key') self.assertEqual(re._get_modified_info_dict(), {'key1': 'val1'}) re._del_modified_info_dict_key('key1') self.assertEqual(re._get_modified_info_dict(), {}) re._set_modified_info_dict('key2', 'val2') self.assertEqual(re._get_modified_info_dict(), {'key2': 'val2'}) re._del_modified_info_dict_keys({'key1': 'val1'}) self.assertEqual(re._get_modified_info_dict(), {'key2': 'val2'}) re._del_modified_info_dict_keys({'key2': 'val2'}) self.assertEqual(re._get_modified_info_dict(), {}) re1 = Resource( self.client, DefaultManager(self.client), ) re1._template = {'key1': '', 'key2': ''} re1._add_details(info={'key1': 'val1'}) self.assertEqual(re1._get_modified_info_dict(), {}) self.assertEqual(re1.key1, 'val1') re1.key1 = 'val1_changed' self.assertEqual(re1._get_modified_info_dict(), {'key1': 'val1_changed'}) self.assertEqual(re1.key1, 'val1_changed') # set attr not in _template re1.key3 = 'val3' self.assertEqual(re1._get_modified_info_dict(), {'key1': 'val1_changed'})
def test_force_get(self): re1 = Resource( self.client, DefaultManager(self.client), ) re1._template = {'key1': '', 'key2': ''} re1._add_details(info={'key1': 'val1'}) self.assertEqual(re1._get_modified_info_dict(), {}) self.assertEqual(re1.key1, 'val1') re1.key1 = 'val1_changed' self.assertEqual(re1._get_modified_info_dict(), {'key1': 'val1_changed'}) self.assertEqual(re1.key1, 'val1_changed') re1._add_details(info={'key1': 'val1'}) self.assertEqual(re1.key1, 'val1_changed') re1._add_details(info={'key1': 'val1'}, force=True) self.assertEqual(re1.key1, 'val1')