def test_set_object(self, mock_get_attr_key): key1, key2 = mock.sentinel.key1, mock.sentinel.key2 val = dsl_types.MuranoObject() val.object_id = mock.sentinel.oid self.attribute_store.set(self.tagged_obj, self.owner_type, self.name, val) self.assertEqual(self.attribute_store._attributes[key1][key2], mock.sentinel.oid)
def test_weak_ref(self, mock_get_object_store): mock_object_store = mock.Mock( **{'get.return_value': mock.sentinel.res}) mock_get_object_store.return_value = mock_object_store test_obj = dsl_types.MuranoObject() setattr(test_obj, 'object_id', generate_uuid()) murano_object_weak_ref = helpers.weak_ref(test_obj) setattr(murano_object_weak_ref, 'ref', lambda *args: None) result = murano_object_weak_ref.__call__() self.assertEqual(mock.sentinel.res, result) self.assertEqual('weakref', murano_object_weak_ref.ref.__class__.__name__)
def test_forget_object(self): obj = dsl_types.MuranoObject() obj.object_id = 'foo' self.attribute_store._attributes = {'foo': 42, 'bar': 43} self.attribute_store.forget_object(obj) self.assertEqual({'bar': 43}, self.attribute_store._attributes)