def test_destroy_removes_ip_address_from_outputs(self): # FIXME(sergmelikyan): Revise this as part of proper fix for #1359998 self.skipTest('skipped until proper fix for #1359998 is proposed') heat_stack_obj = om.Object('io.murano.system.HeatStack') instance_obj = om.Object('io.murano.resources.Instance', name='instance64464', flavor='m1.medium', image='cloud-fedora-v3') runner = self.new_runner({ 'Objects': om.Object('io.murano.Environment', stack=heat_stack_obj, instance=instance_obj), 'Attributes': [ om.Attribute(heat_stack_obj, 'stack', TEMPLATE), om.Attribute(instance_obj, 'fipAssigned', True) ] }) empty_env = runner.serialized_model empty_env['Objects']['instance'] = None model = self.new_runner(empty_env).serialized_model template = self.find_attribute(model, heat_stack_obj.id, heat_stack_obj.type_name, 'stack') instance_name = 'instance64464' ip_addresses = '{0}-assigned-ip'.format(instance_name) floating_ip = '{0}-FloatingIPaddress'.format(instance_name) self.assertNotIn(ip_addresses, template['outputs']) self.assertNotIn(floating_ip, template['outputs']) self.assertNotIn(instance_name, template['resources'])
def test_not_owned_contract(self): arg2 = om.Object('SampleClass2', class2Property='string2') arg1 = om.Object( 'SampleClass1', stringProperty='string1', classProperty=arg2) self.assertIsNone(self._runner.testNotOwnedContract(arg1, arg2))
def setUp(self): super(TestAssignments, self).setUp() self._runner = self.new_runner( om.Object('SampleClass1', stringProperty='string', classProperty=om.Object( 'SampleClass2', class2Property='another string')))
def setUp(self): super(TestMultipleInheritance, self).setUp() self._multi_derived = om.Object('DerivedFrom2Classes', rootProperty='ROOT') model = om.Object('SampleClass3', multiClassProperty=self._multi_derived) self._runner = self.new_runner(model)
def test_dump_with_meta_attributes(self): n1 = om.Object('dumptests.DumpTarget1', foo='FOO') n2 = om.Object('dumptests.DumpTarget1', foo='Bar') source = om.Object('dumptests.DumpTarget3', a=n1, b=n2) result = self._runner.testDump(source) res = self._get_body(result) self._get_body(res['a']) self.assertIsInstance(res['b'], six.string_types)
def setUp(self): super(TestPropertyAccess, self).setUp() self._multi_derived = om.Object('DerivedFrom2Classes', rootProperty='ROOT', ambiguousProperty2=321) model = om.Object('SampleClass3', multiClassProperty=self._multi_derived) self._runner = self.new_runner(model)
def test_template_with_externally_owned_object(self): node = om.Object('Node', 'OBJ_ID') node_template = om.Object('Node', nodes=['OBJ_ID']) model = om.Object('TemplatePropertyClass', owned=node, template=node_template) runner = self.new_runner(model) self.assertEqual(['OBJ_ID'], runner.testTemplateWithExternallyOwnedObject())
def setUp(self): super(TestContracts, self).setUp() self._runner = self.new_runner( om.Object('ContractExamples', ordinaryProperty='PROPERTY', sampleClass=om.Object('SampleClass1', stringProperty='string1', classProperty=om.Object( 'SampleClass2', class2Property='string2'))))
def setUp(self): super(TestResultsSerializer, self).setUp() self._class2 = om.Object('SampleClass2', class2Property='string2') self._class1 = om.Object('SampleClass1', stringProperty='string1', classProperty=self._class2) self._root_class = om.Object('ContractExamples', sampleClass=self._class1) self._runner = self.new_runner(self._root_class)
def test_owned_contract_failure(self): arg1 = self._runner.root.get_property('sampleClass') arg2 = arg1.get_property('classProperty') invalid_arg2 = om.Object('SampleClass2', class2Property='string2') invalid_arg1 = om.Object('SampleClass1', stringProperty='string1', classProperty=invalid_arg2) self.assertRaises(exceptions.ContractViolationException, self._runner.testOwnedContract, invalid_arg1, arg2) self.assertRaises(exceptions.ContractViolationException, self._runner.testOwnedContract, invalid_arg2, arg1)
def setUp(self): super(ModifyActionTestCase, self).setUp() self._list_member = om.Object('SampleClass2', class2Property='string2') self._dict_member = om.Object('SampleClass2', class2Property='string2') self._runner = self.new_runner( om.Object( 'ModelExamples', sampleClass=om.Object( 'SampleClass1', stringProperty='string1', dictProperty={1: 'a', 2: 'b'}, dictClassProperty={ 'key': self._dict_member}, classProperty=[self._list_member]))) self._obj = self._runner.root
def test_template_contract_with_property_exclusion(self): arg = om.Object('CreatedClass2', property1='qwerty', property2='INVALID') result = self._runner.testTemplateContractExcludeProperty(arg) self.assertIsInstance(result, dict) self.assertItemsEqual(['?', 'property1'], result.keys())
def test_same_ref_dump(self): nested = om.Object('dumptests.DumpTarget1', foo='FOO') source = om.Object('dumptests.DumpTarget2', nested=nested, another=nested, ref=nested) result = self._runner.testDump(source) res = self._get_body(result) string_keys = [k for k in res.keys() if isinstance(res[k], str)] obj_keys = [k for k in res.keys() if isinstance(res[k], dict)] self.assertEqual(2, len(string_keys)) self.assertEqual(1, len(obj_keys)) obj = self._get_body(res[obj_keys[0]]) self.assertEqual('FOO', obj['foo']) for ref_id in string_keys: self.assertEqual(res[obj_keys[0]]['id'], res[ref_id])
def test_nested(self): n1 = om.Object('dumptests.DumpTarget1', foo='FOO') n2 = om.Object('dumptests.DumpTarget1', foo='BAR') n3 = om.Object('dumptests.DumpTarget1', foo='BAZ') source = om.Object('dumptests.DumpTarget2', nested=n1, another=n2, ref=n3) result = self._runner.testDump(source) res = self._get_body(result) self.assertIsNotNone(res['ref']) self.assertIsNotNone(res['another']) self.assertIsNotNone(res['nested']) self.assertEqual('FOO', self._get_body(res['nested'])['foo']) self.assertEqual('BAR', self._get_body(res['another'])['foo']) self.assertEqual('BAZ', self._get_body(res['ref'])['foo'])
def setUp(self): super(TestAgent, self).setUp() # Register Agent class self.class_loader.import_class(agent.Agent) model = om.Object('AgentTests') self.runner = self.new_runner(model)
def test_empty_provided_version(self): version = '' sem_version = semantic_version.Spec('>=0.0.0', '<1.0.0') model = om.Object('Empty', class_version=version) m = mock.MagicMock(return_value=self._package_loader._package) self._package_loader.load_class_package = m self.new_runner(model) m.assert_called_once_with('Empty', sem_version)
def setUp(self): super(TestAgent, self).setUp() # Register Agent class self.package_loader.load_package('io.murano', None).register_class(agent.Agent) model = om.Object('AgentTests') self.runner = self.new_runner(model)
def test_several_in_row(self): version = '>3.0.0,<=4.1' sem_version = semantic_version.Spec('>3.0.0', '<4.2.0') model = om.Object('Empty', class_version=version) m = mock.MagicMock(return_value=self._package_loader._package) self._package_loader.load_class_package = m self.new_runner(model) m.assert_called_once_with('Empty', sem_version)
def test_model_destroyed(self): model = om.Object('TestGCNode', 'root', value='root', nodes=[ om.Object('TestGCNode', 'node1', value='node1', nodes=['root', 'node2']), om.Object('TestGCNode', 'node2', value='node2', nodes=['root', 'node1']), ]) model = {'Objects': None, 'ObjectsCopy': model} self.new_runner(model) self.assertItemsEqual(['node1', 'node2'], self.traces[:2]) self.assertEqual('root', self.traces[-1])
def setUp(self): super(TestConcurrency, self).setUp() def yield_(): self.traces.append('yield') eventlet.sleep(0) self.register_function(yield_, 'yield') self._runner = self.new_runner(om.Object('TestConcurrency'))
def test_dump_simple_serializable(self): source = om.Object('dumptests.DumpTarget1', foo='FOO', bar=[40, 41, 42], baz={'BAZ': 99}) result = self._runner.testDump(source, 'Serializable') self.assertIn('?', result) self.assertEqual('dumptests.DumpTarget1/0.0.0@tests', result['?']['type'])
def setUp(self): super(TestAgentListener, self).setUp() # Register Agent class self.class_loader.import_class(agent_listener.AgentListener) model = om.Object('AgentListenerTests') self.runner = self.new_runner(model) self.context = yaql.context.Context() self.context.set_data(environment.Environment(), '?environment')
def __init__(self, model, package_loader, functions): if isinstance(model, six.string_types): model = om.Object(model) model = om.build_model(model) if 'Objects' not in model: model = {'Objects': model} self.executor = executor.MuranoDslExecutor( package_loader, TestMockContextManager(functions), execution_session.ExecutionSession()) self._root = self.executor.load(model).object
def __init__(self, model, class_loader): if isinstance(model, types.StringTypes): model = object_model.Object(model) model = object_model.build_model(model) if 'Objects' not in model: model = {'Objects': model} self.executor = executor.MuranoDslExecutor( class_loader, environment.Environment()) self._root = self.executor.load(model)
def test_merged(self): gen1_model = om.Object('TestObjectsCopyMergeSampleClass', 'rootNode', value='node1', nodes=[ om.Object('TestObjectsCopyMergeSampleClass', value='node2', nodes=[om.Ref('rootNode')]) ]) gen2_model = copy.deepcopy(gen1_model) gen2_model['nodes'] = [] gen2_model['value'] = 'node1-updated' model = {'Objects': gen2_model, 'ObjectsCopy': gen1_model} runner = self.new_runner(model) self.assertEqual(['node2', 'node1-updated'], self.traces) self.assertEqual('It works!', runner.testMethod())
def __init__(self, model, package_loader, functions): if isinstance(model, types.StringTypes): model = object_model.Object(model) model = object_model.build_model(model) if 'Objects' not in model: model = {'Objects': model} self.executor = executor.MuranoDslExecutor( package_loader, TestContextManager(functions), environment.Environment()) self._root = self.executor.load(model).object
def setUp(self): super(TestAgentListener, self).setUp() # Register Agent class self.package_loader.load_package('io.murano', None).register_class( agent_listener.AgentListener) model = om.Object('AgentListenerTests') self.runner = self.new_runner(model) self.context = yaql_integration.create_empty_context() self.context[constants.CTX_THIS] = mock.MagicMock( dsl.MuranoObjectInterface)
def test_dump_simple_inline(self): source = om.Object('dumptests.DumpTarget1', foo='FOO', bar=[40, 41, 42], baz={'BAZ': 99}) result = self._runner.testDump(source, 'Inline') self.assertIn('id', result) res = self._get_body(result) self.assertEqual('FOO', res['foo']) self.assertEqual([40, 41, 42], res['bar']) self.assertEqual({'BAZ': 99}, res['baz'])
def setUp(self): super(TestAgentListener, self).setUp() # Register Agent class self.package_loader.load_package('io.murano', None).register_class( agent_listener.AgentListener) model = om.Object('AgentListenerTests') self.runner = self.new_runner(model) self.context = yaql_integration.create_empty_context() self.context[constants.CTX_EXECUTION_SESSION] = \ execution_session.ExecutionSession()
def setUp(self): super(TestAgentListener, self).setUp() # Register Agent class self.package_loader.load_package('io.murano', None).register_class( agent_listener.AgentListener) model = om.Object( 'AgentListenerTests') self.runner = self.new_runner(model) self.context = yaql_integration.create_empty_context() self.context[constants.CTX_ENVIRONMENT] = environment.Environment()