From: Ihar Hrachyshka Date: Fri, 27 Feb 2015 12:35:22 +0000 (+0100) Subject: test_metadata_agent: don't check implementation details X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=5c606875ac081479b4be46e07a44d9e3e5ae8a62;p=openstack-build%2Fneutron-build.git test_metadata_agent: don't check implementation details TestUnixDomainMetadataProxy tests too many implementation details when checking cases of existing and non-existing socket file. Reduce mock checks to the minimum needed to test for expected behaviour. Otherwise test may catch wrong isdir() calls (f.e. when policies are initialized) and fail (I experienced it in local checkout). Change-Id: I0f85730e5611a71290542f23f8bdcaaaadbef42c --- diff --git a/neutron/tests/unit/test_metadata_agent.py b/neutron/tests/unit/test_metadata_agent.py index fa6917120..4e5fac39f 100644 --- a/neutron/tests/unit/test_metadata_agent.py +++ b/neutron/tests/unit/test_metadata_agent.py @@ -571,8 +571,6 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase): with mock.patch('os.makedirs') as makedirs: isdir.return_value = False agent.UnixDomainMetadataProxy(mock.Mock()) - - isdir.assert_called_once_with('/the') makedirs.assert_called_once_with('/the', 0o755) def test_init_exists(self): @@ -580,8 +578,6 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase): with mock.patch('os.unlink') as unlink: isdir.return_value = True agent.UnixDomainMetadataProxy(mock.Mock()) - - isdir.assert_called_once_with('/the') unlink.assert_called_once_with('/the/path') def test_init_exists_unlink_no_file(self): @@ -593,10 +589,7 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase): unlink.side_effect = OSError agent.UnixDomainMetadataProxy(mock.Mock()) - - isdir.assert_called_once_with('/the') unlink.assert_called_once_with('/the/path') - exists.assert_called_once_with('/the/path') def test_init_exists_unlink_fails_file_still_exists(self): with mock.patch('os.path.isdir') as isdir: @@ -608,10 +601,7 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase): with testtools.ExpectedException(OSError): agent.UnixDomainMetadataProxy(mock.Mock()) - - isdir.assert_called_once_with('/the') unlink.assert_called_once_with('/the/path') - exists.assert_called_once_with('/the/path') def test_run(self): with mock.patch.object(agent, 'MetadataProxyHandler') as handler: @@ -623,7 +613,6 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase): p = agent.UnixDomainMetadataProxy(self.cfg.CONF) p.run() - isdir.assert_called_once_with('/the') makedirs.assert_called_once_with('/the', 0o755) server.assert_has_calls([ mock.call('neutron-metadata-agent'),