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):
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):
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:
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:
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'),