コード例 #1
0
class RackspaceRebuildTest(unittest.TestCase):

    def setUp(self):
        self.api = mock.Mock(spec=RackspaceApi)
        self.deployer = mock.Mock(spec=ChefDeployer)
        self.command = RackspaceRebuild(rackspace_api=self.api,
                                        chef_deployer=self.deployer)
        self.api.rebuild_node.return_value = Host()

    def test_rebuilds_server_with_api(self):
        server_name = "awesomely named server"
        image = "imageId"
        public_key_file = StringIO("~/.ssh/id_rsa.pub")

        self.command.execute(name=server_name, image=image,
                             public_key_file=public_key_file)

        self.api.rebuild_node.assert_any_call(name=server_name,
                                              image=image,
                                              public_key_file=public_key_file,
                                              progress=sys.stderr)

    def test_deploys_to_host_with_kwargs(self):
        kwargs = {
            'runlist': ['role[web]', 'recipe[test'],
            'plugins': 'bootstrap',
            'post_plugins': 'all_done'
        }
        self.command.execute(name="something",
                             image="imageId",
                             public_key_file=StringIO("whatever"),
                             progress=StringIO(),
                             **kwargs)

        expected_args = {
            'host': Host()
        }
        expected_args.update(kwargs)

        self.deployer.deploy.assert_any_call(**expected_args)

    def test_deploys_to_host_with_environment(self):
        self.command.execute(name="something", image="imageId",
                             public_key_file=StringIO("whatever"),
                             progress=StringIO(),
                             environment='staging')

        expected_host = Host()
        expected_host.environment = 'staging'

        self.deployer.deploy.assert_any_call(host=expected_host)
コード例 #2
0
class RackspaceRebuildTest(unittest.TestCase):
    def setUp(self):
        self.api = mock.Mock(spec=RackspaceApi)
        self.deployer = mock.Mock(spec=ChefDeployer)
        self.command = RackspaceRebuild(rackspace_api=self.api,
                                        chef_deployer=self.deployer)
        self.api.rebuild_node.return_value = Host()

    def test_rebuilds_server_with_api(self):
        server_name = "awesomely named server"
        image = "imageId"
        public_key_file = StringIO("~/.ssh/id_rsa.pub")

        self.command.execute(name=server_name,
                             image=image,
                             public_key_file=public_key_file)

        self.api.rebuild_node.assert_any_call(name=server_name,
                                              image=image,
                                              public_key_file=public_key_file,
                                              progress=sys.stderr)

    def test_deploys_to_host_with_kwargs(self):
        kwargs = {
            'runlist': ['role[web]', 'recipe[test'],
            'plugins': 'bootstrap',
            'post_plugins': 'all_done'
        }
        self.command.execute(name="something",
                             image="imageId",
                             public_key_file=StringIO("whatever"),
                             progress=StringIO(),
                             **kwargs)

        expected_args = {'host': Host()}
        expected_args.update(kwargs)

        self.deployer.deploy.assert_any_call(**expected_args)

    def test_deploys_to_host_with_environment(self):
        self.command.execute(name="something",
                             image="imageId",
                             public_key_file=StringIO("whatever"),
                             progress=StringIO(),
                             environment='staging')

        expected_host = Host()
        expected_host.environment = 'staging'

        self.deployer.deploy.assert_any_call(host=expected_host)
コード例 #3
0
 def setUp(self):
     self.api = mock.Mock(spec=RackspaceApi)
     self.deployer = mock.Mock(spec=ChefDeployer)
     self.command = RackspaceRebuild(rackspace_api=self.api,
                                     chef_deployer=self.deployer)
     self.api.rebuild_node.return_value = Host()
コード例 #4
0
 def setUp(self):
     self.api = mock.Mock(spec=RackspaceApi)
     self.deployer = mock.Mock(spec=ChefDeployer)
     self.command = RackspaceRebuild(rackspace_api=self.api,
                                     chef_deployer=self.deployer)
     self.api.rebuild_node.return_value = Host()