Skip to content
Snippets Groups Projects
Commit 876c7820 authored by Fabrice Le Goff's avatar Fabrice Le Goff
Browse files

check more stuff in CopyThread unittests

parent 4477a201
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ def mocklog(loggername, filename, config): ...@@ -29,7 +29,7 @@ def mocklog(loggername, filename, config):
mocklog.logger = logging.getLogger(__file__) mocklog.logger = logging.getLogger(__file__)
mocklog.logger.setLevel(logging.DEBUG) mocklog.logger.setLevel(logging.DEBUG)
mocklog.logger.addHandler(logging.StreamHandler(sys.stdout)) mocklog.logger.addHandler(logging.StreamHandler(sys.stdout))
mocklog.logger.disabled = True # comment this out if you want the logs #mocklog.logger.disabled = True # comment this out if you want the logs
return mocklog.logger return mocklog.logger
mocklog.logger = None mocklog.logger = None
...@@ -287,7 +287,11 @@ class TestCopyThread(unittest.TestCase): ...@@ -287,7 +287,11 @@ class TestCopyThread(unittest.TestCase):
mock_time.return_value = time() - 10 mock_time.return_value = time() - 10
ct.startTransfers() ct.startTransfers()
self.assertEqual(1, ct.nbtransfers) self.assertEqual(1, ct.nbtransfers)
os.rename.assert_called_once_with(
fmd.file_name + Constants.tobecopied_ext,
fmd.file_name + Constants.copying_ext)
os.rename.reset_mock()
self.c.backend.copystate.return_value = None self.c.backend.copystate.return_value = None
ct.checkTransfers() ct.checkTransfers()
self.assertEqual(1, ct.nbtransfers) self.assertEqual(1, ct.nbtransfers)
...@@ -296,6 +300,16 @@ class TestCopyThread(unittest.TestCase): ...@@ -296,6 +300,16 @@ class TestCopyThread(unittest.TestCase):
os.kill.assert_called_once_with(751981, signal.SIGKILL) os.kill.assert_called_once_with(751981, signal.SIGKILL)
self.c.backend.remove.assert_called_once_with(dst, fmd.eos_instance, ANY) self.c.backend.remove.assert_called_once_with(dst, fmd.eos_instance, ANY)
self.assertEqual(1, ct.transfers[0].retry) self.assertEqual(1, ct.transfers[0].retry)
os.rename.assert_not_called()
self.c.backend.copystate.return_value = 0
ct.checkTransfers()
self.assertEqual(0, ct.nbtransfers)
self.assertEqual(1, ct.files_copied)
self.assertEqual(1, ct.simple_transfer_failures)
os.rename.assert_called_once_with(
fmd.file_name + Constants.copying_ext,
fmd.file_name + Constants.copied_ext)
@unittest.mock.patch('cs.Threads.CopyThread.dir_is_locked') @unittest.mock.patch('cs.Threads.CopyThread.dir_is_locked')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment