Fix up unit tests

This commit is contained in:
Liam Young
2020-07-07 12:18:01 +00:00
parent a829b372e0
commit 76fdb61e0f
3 changed files with 8 additions and 2 deletions
@@ -581,17 +581,23 @@ class TestOpenStackUtils(ut_utils.BaseTestCase):
nova_mock.keypairs.create.assert_called_once_with(name='mykeys')
def test_get_private_key_file(self):
self.patch_object(openstack_utils.deployment_env, 'get_tmpdir',
return_value=False)
self.get_tmpdir.return_value = '/tmp/zaza-model1'
self.assertEqual(
openstack_utils.get_private_key_file('mykeys'),
'tests/id_rsa_mykeys')
'/tmp/zaza-model1/id_rsa_mykeys')
def test_write_private_key(self):
self.patch_object(openstack_utils.deployment_env, 'get_tmpdir',
return_value=False)
self.get_tmpdir.return_value = '/tmp/zaza-model1'
m = mock.mock_open()
with mock.patch(
'zaza.openstack.utilities.openstack.open', m, create=False
):
openstack_utils.write_private_key('mykeys', 'keycontents')
m.assert_called_once_with('tests/id_rsa_mykeys', 'w')
m.assert_called_once_with('/tmp/zaza-model1/id_rsa_mykeys', 'w')
handle = m()
handle.write.assert_called_once_with('keycontents')
Binary file not shown.