diff --git a/test/unit/container/test_updater.py b/test/unit/container/test_updater.py index 507daf992a..c2ad673236 100644 --- a/test/unit/container/test_updater.py +++ b/test/unit/container/test_updater.py @@ -75,7 +75,8 @@ class TestContainerUpdater(unittest.TestCase): self.assertTrue(cu.get_account_ring() is not None) @mock.patch.object(container_updater, 'ismount') - def test_run_once_with_device_unmounted(self, mock_ismount): + @mock.patch.object(container_updater.ContainerUpdater, 'container_sweep') + def test_run_once_with_device_unmounted(self, mock_sweep, mock_ismount): mock_ismount.return_value = False cu = container_updater.ContainerUpdater({ @@ -89,9 +90,17 @@ class TestContainerUpdater(unittest.TestCase): }) containers_dir = os.path.join(self.sda1, DATADIR) os.mkdir(containers_dir) + partition_dir = os.path.join(containers_dir, "a") + os.mkdir(partition_dir) + cu.run_once() self.assertTrue(os.path.exists(containers_dir)) # sanity check + # only called if a partition dir exists + self.assertTrue(mock_sweep.called) + + mock_sweep.reset_mock() + cu = container_updater.ContainerUpdater({ 'devices': self.devices_dir, 'mount_check': 'true', @@ -107,6 +116,8 @@ class TestContainerUpdater(unittest.TestCase): self.assertTrue(len(log_lines) > 0) msg = 'sda1 is not mounted' self.assertEqual(log_lines[0], msg) + # Ensure that the container_sweep did not run + self.assertFalse(mock_sweep.called) def test_run_once(self): cu = container_updater.ContainerUpdater({