class SoftwareDeploymentTest(testtools.TestCase):

    def setUp(self):
        super(SoftwareDeploymentTest, self).setUp()
        deployment_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
        self.deployment = SoftwareDeployment(
            mock.MagicMock(), info={'id': deployment_id})
        self.deployment_id = deployment_id

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

    def test_update(self):
        self.assertEqual(
            "<SoftwareDeployment {'id': '%s'}>" % self.deployment_id,
            str(self.deployment))
        self.deployment.manager.update.return_value = None
        config_id = 'd00ba4aa-db33-42e1-92f4-2a6469260107'
        self.assertIsNone(self.deployment.update(config_id=config_id))
        kwargs = self.deployment.manager.update.call_args[1]
        self.assertEqual(self.deployment_id, kwargs['deployment_id'])
        self.assertEqual(config_id, kwargs['config_id'])
    def test_get(self):
        deployment_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
        config_id = 'd00ba4aa-db33-42e1-92f4-2a6469260107'
        server_id = 'fb322564-7927-473d-8aad-68ae7fbf2abf'
        data = {
            'id': deployment_id,
            'server_id': server_id,
            'input_values': {},
            'output_values': {},
            'action': 'INIT',
            'status': 'COMPLETE',
            'status_reason': None,
            'signal_id': None,
            'config_id': config_id,
            'config': '#!/bin/bash',
            'name': 'config_mysql',
            'group': 'Heat::Shell',
            'inputs': [],
            'outputs': [],
            'options': []
        }

        self.manager.client.json_request.return_value = ({}, {
            'software_deployment':
            data
        })
        result = self.manager.get(deployment_id=deployment_id)
        self.assertEqual(SoftwareDeployment(self.manager, data), result)
        call_args = self.manager.client.json_request.call_args
        self.assertEqual(('GET', '/software_deployments/%s' % deployment_id),
                         *call_args)
 def test_update(self):
     deployment_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
     config_id = 'd00ba4aa-db33-42e1-92f4-2a6469260107'
     server_id = 'fb322564-7927-473d-8aad-68ae7fbf2abf'
     body = {
         'server_id': server_id,
         'input_values': {},
         'action': 'DEPLOYED',
         'status': 'COMPLETE',
         'status_reason': None,
         'signal_id': None,
         'config_id': config_id
     }
     data = body.copy()
     data['id'] = deployment_id
     self.manager.client.json_request.return_value = ({}, {
         'software_deployment':
         data
     })
     result = self.manager.update(deployment_id, **body)
     self.assertEqual(SoftwareDeployment(self.manager, data), result)
     args, kwargs = self.manager.client.json_request.call_args
     self.assertEqual('PUT', args[0])
     self.assertEqual('/software_deployments/%s' % deployment_id, args[1])
     self.assertEqual({'data': body}, kwargs)
class SoftwareDeploymentTest(testtools.TestCase):
    def setUp(self):
        super(SoftwareDeploymentTest, self).setUp()
        deployment_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
        self.deployment = SoftwareDeployment(mock.MagicMock(),
                                             info={'id': deployment_id})
        self.deployment_id = deployment_id

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

    def test_update(self):
        self.assertEqual(
            "<SoftwareDeployment {'id': '%s'}>" % self.deployment_id,
            str(self.deployment))
        self.deployment.manager.update.return_value = None
        config_id = 'd00ba4aa-db33-42e1-92f4-2a6469260107'
        self.assertIsNone(self.deployment.update(config_id=config_id))
        kwargs = self.deployment.manager.update.call_args[1]
        self.assertEqual(self.deployment_id, kwargs['deployment_id'])
        self.assertEqual(config_id, kwargs['config_id'])
 def setUp(self):
     super(SoftwareDeploymentTest, self).setUp()
     deployment_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
     self.deployment = SoftwareDeployment(mock.MagicMock(),
                                          info={'id': deployment_id})
     self.deployment_id = deployment_id
 def setUp(self):
     super(SoftwareDeploymentTest, self).setUp()
     deployment_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57'
     self.deployment = SoftwareDeployment(
         mock.MagicMock(), info={'id': deployment_id})
     self.deployment_id = deployment_id