<div dir="ltr">
<div class="" lang="x-western">
  

    
  
  
    <tt>I was writing this in test_glusterfs.py<br>
      <br>
          def test_ensure_shares_unmounted_1share(self):<br>
              with contextlib.nested(<br>
                  mock.patch.object(self._driver,
      '_load_shares_config'),<br>
                  mock.patch.object(self._driver,
      '_ensure_share_unmounted')<br>
              ) as (self._fake_load_shares_config,
      mock_ensure_share_unmounted):<br>
      <br>
                  #mock_shares = {'127.7.7.7:/gluster1': None}<br>
                  #mock_load_shares_config.return_value = mock_shares<br>
                  #self._driver.shares =
      mock_load_shares_config.return_value<br>
      <br>
                  self._driver._ensure_shares_unmounted()<br>
      <br>
                  mock_ensure_share_unmounted.assert_called_once()<br>
                  mock_ensure_share_unmounted.assert_called_once_with(<br>
                      '127.7.7.7:/gluster1')<br>
      <br>
      for my patch @ <a class="" href="https://review.openstack.org/#/c/86888/6">https://review.openstack.org/#/c/86888/6</a><br>
      <br>
      and i get the output as ..<br>
      <br>
======================================================================<br>
      FAIL:
cinder.tests.test_glusterfs.GlusterFsDriverTestCase.test_ensure_shares_unmounted_1share<br>
----------------------------------------------------------------------<br>
      ...<br>
      ...<br>
      <br>
      stderr: {{{<br>
      cinder/tests/test_glusterfs.py:736: DeprecationWarning:
      With-statements now directly support multiple context managers<br>
        mock.patch.object(self._driver, '_ensure_share_unmounted')<br>
      }}}<br>
      <br>
      Traceback (most recent call last):<br>
        File "cinder/tests/test_glusterfs.py", line 747, in
      test_ensure_shares_unmounted_1share<br>
          '127.7.7.7:/gluster1')<br>
        File "/usr/lib/python2.7/site-packages/mock.py", line 845, in
      assert_called_once_with<br>
          raise AssertionError(msg)<br>
      AssertionError: Expected to be called once. Called 0 times.<br>
      <br>
      <br>
      Can you help with why <br>
      </tt><tt>'mock_ensure_share_unmounted.assert_called_once()'
        check passes<br>
        but<br>
        '</tt><tt><tt>mock_ensure_share_unmounted.assert_called_once_with(</tt></tt><tt><tt><tt>'127.7.7.7:/gluster1')
            check fails ?<br>
          <br>
          <br>
          In glusterfs.py ...<br>
          <br>
              def _ensure_shares_unmounted(self):<br>
                 
          self._load_shares_config(self.configuration.glusterfs_shares_config)<br>
                  for share in self.shares.keys():<br>
                      try:<br>
                          self._ensure_share_unmounted(share)<br>
                      except Exception as exc:<br>
                          LOG.warning(_('Exception during unmounting
          %s') % (exc,))<br>
          <br>
        </tt></tt><br>
      thanx,<br>
      deepak<br>
      <br>
    </tt>
  


</div>

</div>