From: Ross Brattain <ross.b.brattain@intel.com>
Date: Wed, 18 Apr 2018 00:07:43 +0000 (-0700)
Subject: fix unittest test_deploy_try_retrieve_context_does_not_exist
X-Git-Tag: opnfv-7.0.0~359
X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=be5e495a1cb7ab97b9202900defaf00dbd773054;p=yardstick.git

fix unittest test_deploy_try_retrieve_context_does_not_exist

unittest is failing due to mock being called multiple times.

I assume this is due to parallelization of tests in Jenkins somehow

======================================================================
FAIL: test_deploy_try_retrieve_context_does_not_exist (benchmark.contexts.test_heat.HeatContextTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jenkins/opnfv/slave_root/workspace/yardstick-verify-master/.tox/py3/lib/python3.5/site-packages/mock/mock.py", line 1305, in patched
    return func(*args, **keywargs)
  File "/home/jenkins/opnfv/slave_root/workspace/yardstick-verify-master/yardstick/tests/unit/benchmark/contexts/test_heat.py", line 309, in test_deploy_try_retrieve_context_does_not_exist
    mock_path_exists.assert_called_once_with(key_filename)
  File "/home/jenkins/opnfv/slave_root/workspace/yardstick-verify-master/.tox/py3/lib/python3.5/site-packages/mock/mock.py", line 947, in assert_called_once_with
    raise AssertionError(msg)
AssertionError: Expected 'exists' to be called once. Called 3 times.

----------------------------------------------------------------------

Change-Id: I696c63ef9f7943b841e2d3d533c92f18aa7044da
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
---

diff --git a/yardstick/tests/unit/benchmark/contexts/test_heat.py b/yardstick/tests/unit/benchmark/contexts/test_heat.py
index 625f97bf4..a40adf5ae 100644
--- a/yardstick/tests/unit/benchmark/contexts/test_heat.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_heat.py
@@ -306,7 +306,7 @@ class HeatContextTestCase(unittest.TestCase):
              'yardstick/resources/files/yardstick_key-',
              self.test_context._name])
         mock_genkeys.assert_called_once_with(key_filename)
-        mock_path_exists.assert_called_once_with(key_filename)
+        mock_path_exists.assert_any_call(key_filename)
 
     @mock.patch.object(heat, 'HeatTemplate', return_value='heat_template')
     @mock.patch.object(heat.HeatContext, '_add_resources_to_template')