class SoftwareConfigTest(testtools.TestCase):
    def setUp(self):
        super(SoftwareConfigTest, self).setUp()
        config_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
        self.config = SoftwareConfig(mock.MagicMock(), info={'id': config_id})
        self.config_id = config_id

    def test_delete(self):
        self.config.manager.delete.return_value = None
        self.assertIsNone(self.config.delete())
        kwargs = self.config.manager.delete.call_args[1]
        self.assertEqual(self.config_id, kwargs['config_id'])

    def test_data(self):
        self.assertEqual("<SoftwareConfig {'id': '%s'}>" % self.config_id,
                         str(self.config))
        self.config.manager.data.return_value = None
        self.config.data(name='config_mysql')
        kwargs = self.config.manager.data.call_args[1]
        self.assertEqual('config_mysql', kwargs['name'])
class SoftwareConfigTest(testtools.TestCase):

    def setUp(self):
        super(SoftwareConfigTest, self).setUp()
        config_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
        self.config = SoftwareConfig(mock.MagicMock(), info={'id': config_id})
        self.config_id = config_id

    def test_delete(self):
        self.config.manager.delete.return_value = None
        self.assertIsNone(self.config.delete())
        kwargs = self.config.manager.delete.call_args[1]
        self.assertEqual(self.config_id, kwargs['config_id'])

    def test_data(self):
        self.assertEqual(
            "<SoftwareConfig {'id': '%s'}>" % self.config_id, str(self.config))
        self.config.manager.data.return_value = None
        self.config.data(name='config_mysql')
        kwargs = self.config.manager.data.call_args[1]
        self.assertEqual('config_mysql', kwargs['name'])
    def test_get(self):
        config_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
        data = {
            'id': config_id,
            'name': 'config_mysql',
            'group': 'Heat::Shell',
            'config': '#!/bin/bash',
            'inputs': [],
            'ouputs': [],
            'options': []
        }

        self.manager.client.json_request.return_value = ({}, {
            'software_config':
            data
        })
        result = self.manager.get(config_id=config_id)
        self.assertEqual(SoftwareConfig(self.manager, data), result)
        call_args = self.manager.client.json_request.call_args
        self.assertEqual(('GET', '/software_configs/%s' % config_id),
                         *call_args)
 def test_create(self):
     config_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
     body = {
         'name': 'config_mysql',
         'group': 'Heat::Shell',
         'config': '#!/bin/bash',
         'inputs': [],
         'ouputs': [],
         'options': []
     }
     data = body.copy()
     data['id'] = config_id
     self.manager.client.json_request.return_value = ({}, {
         'software_config':
         data
     })
     result = self.manager.create(**body)
     self.assertEqual(SoftwareConfig(self.manager, data), result)
     args, kargs = self.manager.client.json_request.call_args
     self.assertEqual('POST', args[0])
     self.assertEqual('/software_configs', args[1])
     self.assertEqual({'data': body}, kargs)
 def setUp(self):
     super(SoftwareConfigTest, self).setUp()
     config_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
     self.config = SoftwareConfig(mock.MagicMock(), info={'id': config_id})
     self.config_id = config_id
 def setUp(self):
     super(SoftwareConfigTest, self).setUp()
     config_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
     self.config = SoftwareConfig(mock.MagicMock(), info={'id': config_id})
     self.config_id = config_id