diff options
author | wu.zhihui <wu.zhihui1@zte.com.cn> | 2016-10-22 17:02:33 +0800 |
---|---|---|
committer | wu.zhihui <wu.zhihui1@zte.com.cn> | 2016-10-28 14:09:08 +0800 |
commit | 2e1c1d51ec76e9d6e2c39538594659c8d0cc4331 (patch) | |
tree | 2ce2fdf5e86c0c87780055d7d68820be6d7b5314 /tests | |
parent | 492c8a551b6d5b745c54c2fa086eee1e02e97c62 (diff) |
Code refactor: spawn_vm.py
1. update SampleHeat.yaml
2. No need to fetch private key file my_key.pem.
3. remove keypair value from spawn_vm_test.py
4. cleanup redundant code.
Change-Id: Id7ccdbae5b88c86ebff7518710b6c91ab4281c53
Signed-off-by: wu.zhihui <wu.zhihui1@zte.com.cn>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/spawn_vm_test.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/tests/spawn_vm_test.py b/tests/spawn_vm_test.py index 7890abd1..fca7dd00 100644 --- a/tests/spawn_vm_test.py +++ b/tests/spawn_vm_test.py @@ -17,9 +17,7 @@ class StackMock(MagicMock): {'output_key': 'instance_ip_1', "output_value": "172.10.0.154"}, {"output_key": "instance_PIP_1", - "output_value": "10.10.17.5"}, - {'output_key': 'KeyPair_PublicKey', - "output_value": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpwIBAAKCAQEAqCiHcrLBXtxG0LhnKndU7VIVpYxORmv0d4tvujkWOkYuagiW\nU/MTRk0zhRvFQDVPEs0Jrj/BIecqm6fjjT6dZ/H7JLYGaqJitRkoupKgBsMSIqUz\nrR0ekOlfXZ6N+Ud8k6s+qjc7BO4b1ezz78jHisC5o0GCkUV0ECx64Re1fO+oKs1c\nfL9aaexahJUYN3J48pazQz+imc2x/G9nuqHX3cqEszmxnT4jwv//In1GjHy2AyXw\n1oA5F6wZoQCSrXc2BditU+1tlVhEkPFt5JgiHUpY8T8mYbroT7JH6xjcGSKUN+HG\nN8PXNUTD1VAQfwHpkfsGMfDyzjytCXsoTEOqnwIDA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wR5sQKCAIAvPWq+bvcPTDKUU1Fe/Y/GyWoUA+uSqmCdORBkK38lALFGphxj\nfDz9dXskimqW+A9hOPOS8dm8YcVvi/TLXVE5Vsx9VkOg6z6AZBQpgNXGfOgpju4W\nbjER7bQaASatuWQyCxbA9oNlAUdSeOhGTxeFLkLj7hNMd6tLjfd8w7A/hA==\n-----END RSA PRIVATE KEY-----\n"}] + "output_value": "10.10.17.5"}] class HeatMock(MagicMock): @@ -44,16 +42,15 @@ class TestClass: ]) @mock.patch('func.spawn_vm.Env_setup') @mock.patch('func.spawn_vm.AvailabilityZone') - @mock.patch('func.spawn_vm.client', autospec=True) @mock.patch('func.spawn_vm.keystoneclient.v2_0', autospec=True) @mock.patch('func.spawn_vm.heatclient.client', autospec=True) def test_create_zones_success(self, mock_heat, mock_keystone, - mock_nova_client, mock_zone, - mock_setup, test_input, expected): - mock_nova_client.Client.return_value = Mock() + mock_zone, mock_setup, test_input, expected): + open('./config/QtipKey.pub', 'a').close() mock_heat.Client.return_value = Mock(stacks=HeatMock()) k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel'}) k.start() SpawnVM(test_input) k.stop() + os.remove('./config/QtipKey.pub') mock_setup.ip_pw_list.append.assert_called_with(expected[0]) |