Esempio n. 1
0
 def test_run_existing_pubkey(self, get_workflow_client_mock):
     mistral = mock.MagicMock()
     get_workflow_client_mock.return_value = mistral
     environment = collections.namedtuple('environment', ['variables'])
     mistral.environments.get.return_value = environment(
         variables={'public_key': 'existing_pubkey'})
     action = validations.GetPubkeyAction()
     self.assertEqual('existing_pubkey', action.run())
Esempio n. 2
0
    def test_run_no_pubkey(self, mock_create_keypair,
                           get_workflow_client_mock):
        mistral = mock.MagicMock()
        get_workflow_client_mock.return_value = mistral
        mistral.environments.get.side_effect = 'nope, sorry'
        mock_create_keypair.return_value = {
            'public_key': 'public_key',
            'private_key': 'private_key',
        }

        action = validations.GetPubkeyAction()
        self.assertEqual('public_key', action.run())