Beispiel #1
0
class BaseCommandTest(CommandBase):

    def setUp(self):
        super(BaseCommandTest, self).setUp()
        self.cmd = BaseCommand(self.config, self.provider, self.env)

    def test_get_ssh_keys(self):
        self.provider.get_ssh_keys.return_value = [
            SSHKey({'id': 1, 'label': 'abc'}),
            SSHKey({'id': 32, 'label': 'bcd'})]
        self.assertEqual(
            self.cmd.get_slayer_ssh_keys(),
            [1, 32])

    def test_check_preconditions_okay(self):
        self.setup_env()
        self.assertEqual(self.cmd.check_preconditions(), [1])

    def test_check_preconditions_host_exist(self):
        self.setup_env({
            'environments': {
                'softlayer': {
                    'type': 'null',
                    'bootstrap-host': '1.1.1.1'}}})
        try:
            self.cmd.check_preconditions()
        except ConfigError, e:
            self.assertIn('already has a bootstrap-host', str(e))
        else:
Beispiel #2
0
 def setUp(self):
     super(BaseCommandTest, self).setUp()
     self.cmd = BaseCommand(self.config, self.provider, self.env)