class SoftwareConfigManagerTest(testtools.TestCase):
    def setUp(self):
        super(SoftwareConfigManagerTest, self).setUp()
        self.manager = SoftwareConfigManager(mock.MagicMock())

    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 test_delete(self):
        config_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
        self.manager.delete(config_id)
        call_args = self.manager.client.delete.call_args
        self.assertEqual(('/software_configs/%s' % config_id, ), *call_args)
class SoftwareConfigManagerTest(testtools.TestCase):

    def setUp(self):
        super(SoftwareConfigManagerTest, self).setUp()
        self.manager = SoftwareConfigManager(mock.MagicMock())

    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 test_delete(self):
        config_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
        self.manager.delete(config_id)
        call_args = self.manager.client.delete.call_args
        self.assertEqual(
            ('/software_configs/%s' % config_id,), *call_args)
 def setUp(self):
     super(SoftwareConfigManagerTest, self).setUp()
     self.manager = SoftwareConfigManager(mock.MagicMock())
 def setUp(self):
     super(SoftwareConfigManagerTest, self).setUp()
     self.manager = SoftwareConfigManager(mock.MagicMock())