コード例 #1
0
ファイル: test_commands.py プロジェクト: ccird/juju-softlayer
class DestroyEnvironmentTest(CommandBase):

    def setUp(self):
        super(DestroyEnvironmentTest, self).setUp()
        self.cmd = DestroyEnvironment(self.config, self.provider, self.env)

    @mock.patch('juju_slayer.commands.time')
    def test_destroy_environment(self, mock_time):
        self.setup_env()
        self.env.status.return_value = {
            'machines': {
                '0': {
                    'dns-name': '10.0.1.23',
                    'instance-id': 'manual:ip_address'},
                '1': {
                    'dns-name': '10.0.1.25',
                    'instance-id': 'manual:ip_address'}
            }}
        self.provider.get_instances.return_value = [
            Instance(dict(
                id=221, hostname="slayer-123123",
                primaryIpAddress="10.0.1.23")),
            Instance(dict(
                id=258, hostname="slayer-209123",
                primaryIpAddress="10.0.1.25"))]

        # Destroy Env has a sleep / mock it out.
        mock_time.sleep.return_value = None
        self.cmd.run()
        self.assertEqual(
            self.provider.terminate_instance.call_args_list,
            [mock.call(258), mock.call(221)])
        self.env.terminate_machines.assert_called_once_with(['1'])
コード例 #2
0
ファイル: test_commands.py プロジェクト: ccird/juju-softlayer
 def setUp(self):
     super(DestroyEnvironmentTest, self).setUp()
     self.cmd = DestroyEnvironment(self.config, self.provider, self.env)