def test_create(self):
     ctx = self.get_mock_ctx("NetworkInterface")
     config = {NETWORKINTERFACE_ID: 'eni', SUBNET_ID: 'subnet'}
     self.eni.resource_id = config[NETWORKINTERFACE_ID]
     iface = MagicMock()
     iface.create = self.mock_return({'NetworkInterface': config})
     eni.create(ctx, iface, config)
     self.assertEqual(self.eni.resource_id, 'eni')
 def test_create_with_relationships(self):
     ctx = self.get_mock_ctx("NetworkInterface",
                             type_hierarchy=[SUBNET_TYPE])
     config = {NETWORKINTERFACE_ID: 'eni'}
     self.eni.resource_id = config[NETWORKINTERFACE_ID]
     iface = MagicMock()
     iface.create = self.mock_return({'NetworkInterface': config})
     with patch('cloudify_awssdk.common.utils.find_rel_by_node_type'):
         eni.create(ctx, iface, config)
         self.assertEqual(self.eni.resource_id, 'eni')
 def test_create_wth_modify(self):
     ctx = self.get_mock_ctx("NetworkInterface")
     config = {NETWORKINTERFACE_ID: 'eni', SUBNET_ID: 'subnet'}
     self.eni.resource_id = config[NETWORKINTERFACE_ID]
     iface = MagicMock()
     modify_args = {'SourceDestCheck': {'Value': True}}
     iface.create = self.mock_return({'NetworkInterface': config})
     eni.create(ctx,
                iface,
                config,
                modify_network_interface_attribute_args=modify_args)
     self.assertEqual(self.eni.resource_id, 'eni')
 def test_create_with_groups(self):
     mock_rels = [MagicMock()]
     fake_target = self.get_mock_ctx(
         "SecurityGroup",
         test_runtime_properties={'aws_resource_id': 'group3'},
         type_hierarchy=SEC_GROUP_TYPE)
     setattr(mock_rels[0], 'target', fake_target)
     ctx = self.get_mock_ctx("NetworkInterface",
                             test_relationships=mock_rels)
     config = {SUBNET_ID: 'subnet', SEC_GROUPS: ['group1', 'group2']}
     expected = copy.deepcopy(config[SEC_GROUPS])
     expected.append('group3')
     self.eni.resource_id = 'eni'
     iface = MagicMock()
     iface.create = self.mock_return({'NetworkInterface': config})
     eni.create(ctx, iface, config)
     self.assertEqual(self.eni.resource_id, 'eni')
     self.assertEqual(
         ctx.instance.runtime_properties['create_response'][SEC_GROUPS],
         expected)