Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions queue_job/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import traceback
from io import StringIO

from psycopg2 import OperationalError, errorcodes
from werkzeug.exceptions import BadRequest, Forbidden

from odoo import SUPERUSER_ID, _, api, http, registry, tools
from odoo.service.model import PG_CONCURRENCY_ERRORS_TO_RETRY
from psycopg2 import OperationalError, errorcodes
from werkzeug.exceptions import BadRequest, Forbidden

from ..delay import chain, group
from ..exception import FailedJobError, NothingToDoJob, RetryableJobError
Expand Down
1 change: 0 additions & 1 deletion queue_job/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import dateutil
import lxml

from odoo import fields, models
from odoo.tools.func import lazy

Expand Down
2 changes: 1 addition & 1 deletion queue_job/jobrunner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

import logging
from threading import Thread
import time
from threading import Thread

from odoo.service import server
from odoo.tools import config
Expand Down
3 changes: 2 additions & 1 deletion queue_job/jobrunner/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from weakref import WeakValueDictionary

from ..exception import ChannelNotFound
from ..job import CANCELLED, DONE, ENQUEUED, FAILED, PENDING, STARTED, WAIT_DEPENDENCIES
from ..job import (CANCELLED, DONE, ENQUEUED, FAILED, PENDING, STARTED,
WAIT_DEPENDENCIES)

NOT_DONE = (WAIT_DEPENDENCIES, PENDING, ENQUEUED, STARTED, FAILED)

Expand Down
5 changes: 2 additions & 3 deletions queue_job/jobrunner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,11 @@
import time
from contextlib import closing, contextmanager

import odoo
import psycopg2
import requests
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT

import odoo
from odoo.tools import config
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT

from . import queue_job_config
from .channels import ENQUEUED, NOT_DONE, PENDING, ChannelManager
Expand Down
15 changes: 3 additions & 12 deletions queue_job/models/queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,15 @@
from datetime import datetime, timedelta

from odoo import _, api, exceptions, fields, models
from odoo.addons.base_sparse_field.models.fields import Serialized
from odoo.osv import expression
from odoo.tools import config, html_escape

from odoo.addons.base_sparse_field.models.fields import Serialized

from ..delay import Graph
from ..exception import JobError
from ..fields import JobSerialized
from ..job import (
CANCELLED,
DONE,
FAILED,
PENDING,
STARTED,
STATES,
WAIT_DEPENDENCIES,
Job,
)
from ..job import (CANCELLED, DONE, FAILED, PENDING, STARTED, STATES,
WAIT_DEPENDENCIES, Job)

_logger = logging.getLogger(__name__)

Expand Down
8 changes: 0 additions & 8 deletions queue_job/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
from . import test_runner_channels
from . import test_runner_runner
from . import test_delayable
from . import test_json_field
from . import test_model_job_channel
from . import test_model_job_function
from . import test_queue_job_protected_write
from . import test_wizards
9 changes: 4 additions & 5 deletions queue_job/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
from operator import attrgetter
from unittest import TestCase, mock

from odoo.tests.case import TestCase as _TestCase
from odoo.tests.common import MetaCase

from odoo.addons.queue_job.delay import Graph

# pylint: disable=odoo-addons-relative-import
from odoo.addons.queue_job.job import Job
from odoo.tests.case import TestCase as _TestCase
from odoo.tests.common import MetaCase


@contextmanager
Expand Down Expand Up @@ -212,7 +210,8 @@ def assert_enqueued_job(self, method, args=None, kwargs=None, properties=None):

if expected_call not in actual_calls:
raise AssertionError(
"Job {} was not enqueued.\n" "Actual enqueued jobs:\n{}".format(
"Job {} was not enqueued.\n"
"Actual enqueued jobs:\n{}".format(
self._format_job_call(expected_call),
"\n".join(
f" * {self._format_job_call(call)}" for call in actual_calls
Expand Down
4 changes: 1 addition & 3 deletions queue_job/tests/test_json_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
from datetime import date, datetime

from lxml import etree

from odoo.tests import common

# pylint: disable=odoo-addons-relative-import
# we are testing, we want to test as we were an external consumer of the API
from odoo.addons.queue_job.fields import JobDecoder, JobEncoder
from odoo.tests import common


class TestJson(common.TransactionCase):
Expand Down
3 changes: 1 addition & 2 deletions queue_job/tests/test_model_job_channel.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# copyright 2018 Camptocamp
# license lgpl-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

from psycopg2 import IntegrityError

import odoo
from odoo.tests import common
from psycopg2 import IntegrityError


class TestJobChannel(common.TransactionCase):
Expand Down
1 change: 0 additions & 1 deletion queue_job_cron/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from . import test_queue_job_cron
13 changes: 4 additions & 9 deletions queue_job_cron_jobrunner/models/queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@
import traceback
from io import StringIO

from psycopg2 import OperationalError

from odoo import _, api, models, tools
from odoo.service.model import PG_CONCURRENCY_ERRORS_TO_RETRY

from odoo.addons.queue_job.controllers.main import PG_RETRY
from odoo.addons.queue_job.exception import (
FailedJobError,
NothingToDoJob,
RetryableJobError,
)
from odoo.addons.queue_job.exception import (FailedJobError, NothingToDoJob,
RetryableJobError)
from odoo.addons.queue_job.job import Job
from odoo.service.model import PG_CONCURRENCY_ERRORS_TO_RETRY
from psycopg2 import OperationalError

_logger = logging.getLogger(__name__)

Expand Down
1 change: 0 additions & 1 deletion queue_job_cron_jobrunner/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from . import test_queue_job
1 change: 0 additions & 1 deletion queue_job_cron_jobrunner/tests/test_queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from datetime import timedelta

from freezegun import freeze_time

from odoo import fields
from odoo.tests.common import TransactionCase
from odoo.tools import mute_logger
Expand Down
1 change: 0 additions & 1 deletion queue_job_subscribe/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Copyright 2016 Cédric Pigeon
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_job_subscribe
1 change: 0 additions & 1 deletion queue_job_subscribe/tests/test_job_subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import odoo.tests.common as common

from odoo.addons.queue_job.job import Job


Expand Down
1 change: 0 additions & 1 deletion test_queue_job/models/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

from odoo import api, fields, models

from odoo.addons.queue_job.delay import chain
from odoo.addons.queue_job.exception import RetryableJobError
from odoo.addons.queue_job.job import identity_exact
Expand Down
8 changes: 0 additions & 8 deletions test_queue_job/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
from . import test_autovacuum
from . import test_delayable
from . import test_dependencies
from . import test_job
from . import test_job_auto_delay
from . import test_job_channels
from . import test_related_actions
from . import test_delay_mocks
3 changes: 1 addition & 2 deletions test_queue_job/tests/common.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Copyright 2016-2019 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

from odoo.tests import common

from odoo.addons.queue_job.job import Job
from odoo.tests import common


class JobCommonCase(common.TransactionCase):
Expand Down
3 changes: 1 addition & 2 deletions test_queue_job/tests/test_delay_mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
from unittest import mock

import odoo.tests.common as common
from odoo.tools import mute_logger

from odoo.addons.queue_job.delay import Delayable
from odoo.addons.queue_job.job import identity_exact
from odoo.addons.queue_job.tests.common import mock_with_delay, trap_jobs
from odoo.tools import mute_logger


class TestDelayMocks(common.TransactionCase):
Expand Down
10 changes: 2 additions & 8 deletions test_queue_job/tests/test_delayable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
# license lgpl-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

import odoo.tests.common as common

from odoo.addons.queue_job.delay import (
Delayable,
DelayableChain,
DelayableGroup,
chain,
group,
)
from odoo.addons.queue_job.delay import (Delayable, DelayableChain,
DelayableGroup, chain, group)


class TestDelayable(common.TransactionCase):
Expand Down
1 change: 0 additions & 1 deletion test_queue_job/tests/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

import odoo.tests.common as common

from odoo.addons.queue_job.delay import DelayableGraph, chain, group
from odoo.addons.queue_job.job import PENDING, WAIT_DEPENDENCIES, Job

Expand Down
21 changes: 5 additions & 16 deletions test_queue_job/tests/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,13 @@
from unittest import mock

import odoo.tests.common as common

from odoo.addons.queue_job import identity_exact
from odoo.addons.queue_job.delay import DelayableGraph
from odoo.addons.queue_job.exception import (
FailedJobError,
NoSuchJobError,
RetryableJobError,
)
from odoo.addons.queue_job.job import (
DONE,
ENQUEUED,
FAILED,
PENDING,
RETRY_INTERVAL,
STARTED,
WAIT_DEPENDENCIES,
Job,
)
from odoo.addons.queue_job.exception import (FailedJobError, NoSuchJobError,
RetryableJobError)
from odoo.addons.queue_job.job import (DONE, ENQUEUED, FAILED, PENDING,
RETRY_INTERVAL, STARTED,
WAIT_DEPENDENCIES, Job)

from .common import JobCommonCase

Expand Down
3 changes: 1 addition & 2 deletions test_queue_job/tests/test_job_auto_delay.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Copyright 2020 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

from odoo.tests.common import tagged

from odoo.addons.queue_job.job import Job
from odoo.tests.common import tagged

from .common import JobCommonCase

Expand Down
1 change: 0 additions & 1 deletion test_queue_job/tests/test_job_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import odoo.tests.common as common
from odoo import exceptions

from odoo.addons.queue_job.job import Job


Expand Down
3 changes: 1 addition & 2 deletions test_queue_job/tests/test_json_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

import json

from odoo.tests import common

# pylint: disable=odoo-addons-relative-import
# we are testing, we want to test as if we were an external consumer of the API
from odoo.addons.queue_job.fields import JobEncoder
from odoo.tests import common


class TestJsonField(common.TransactionCase):
Expand Down
Loading