Beispiel #1
0
    def test_object_id(self):
        _id = 'some_id'
        patch_at = 'muranoapi.dsl.helpers.generate_id'

        obj = murano_object.MuranoObject(self.cls,
                                         None,
                                         None,
                                         None,
                                         object_id=_id)
        with mock.patch(patch_at) as gen_id_mock:
            gen_id_mock.return_value = _id
            obj1 = murano_object.MuranoObject(self.cls, None, None, None)

        self.assertEqual(_id, obj.object_id)
        self.assertEqual(_id, obj1.object_id)
Beispiel #2
0
    def test_fails_internal_property_access(self):
        cls = murano_class.MuranoClass(None, self.resolver, ROOT_CLASS)

        cls.add_property('__hidden',
                         typespec.PropertySpec({'Default': 10}, self.resolver))
        obj = murano_object.MuranoObject(cls, None, None, None)

        self.assertRaises(AttributeError, lambda: obj.__hidden)
Beispiel #3
0
    def test_object_parent_properties_initialization(self):
        root = murano_class.MuranoClass(None, self.resolver, ROOT_CLASS, None)
        cls = murano_class.MuranoClass(None, self.resolver, 'SomeClass', None,
                                       [root])
        root.new = mock.Mock()
        init_kwargs = {'theArg': 0}
        obj = murano_object.MuranoObject(cls, None, None, None)
        expected_calls = [mock.call().initialize(**init_kwargs)]

        obj.initialize(**init_kwargs)

        # each object should also initialize his parent objects
        self.assertEqual(expected_calls, root.new.mock_calls[1:])
Beispiel #4
0
    def test_parent_obj(self):
        parent = mock.Mock()
        obj = murano_object.MuranoObject(self.cls, parent, None, None)

        self.assertEqual(parent, obj.parent)
Beispiel #5
0
    def test_object_valid_type_instantiation(self):
        obj = murano_object.MuranoObject(self.cls, None, None, None)

        self.assertEqual(self.cls, obj.type)