def test_migrate(self, path_exists, mkdir, shutil): unit_id = '123' plan = Mock() path = '/tmp/old/path_1' new_path = '/tmp/new/content/path_2' path_exists.return_value = True # test Unit.migrate(plan, unit_id, path, new_path) # validation path_exists.assert_called_once_with(path) mkdir.assert_called_once_with(os.path.dirname(new_path)) shutil.move.assert_called_once_with(path, new_path) plan.collection.update_one.assert_called_once_with( filter={'_id': unit_id}, update={'$set': {'_storage_path': new_path}})