Merge "mock out os.listdir to return a list"

This commit is contained in:
Jenkins 2014-11-21 03:24:38 +00:00 committed by Gerrit Code Review
commit 308c6a5e73

View File

@ -180,7 +180,7 @@ class TestContainerUpdater(unittest.TestCase):
'permission_denied') 'permission_denied')
self.assertEqual(log_lines[0], msg) self.assertEqual(log_lines[0], msg)
@mock.patch('os.listdir', return_value='bar/') @mock.patch('os.listdir', return_value=['foo', 'bar'])
def test_listdir_without_exception(self, mock_listdir): def test_listdir_without_exception(self, mock_listdir):
cu = container_updater.ContainerUpdater({ cu = container_updater.ContainerUpdater({
'devices': self.devices_dir, 'devices': self.devices_dir,
@ -193,7 +193,7 @@ class TestContainerUpdater(unittest.TestCase):
}) })
cu.logger = FakeLogger() cu.logger = FakeLogger()
path = cu._listdir('foo/bar/') path = cu._listdir('foo/bar/')
self.assertEqual(path, 'bar/') self.assertEqual(path, ['foo', 'bar'])
log_lines = cu.logger.get_lines_for_level('error') log_lines = cu.logger.get_lines_for_level('error')
self.assertEqual(len(log_lines), 0) self.assertEqual(len(log_lines), 0)