Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] [IMP] extendable: Add backup/restore registry methods in test ExtendableMixin #482

Merged
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
20 changes: 19 additions & 1 deletion extendable/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from odoo import api
from odoo.tests import common

from extendable import context
from extendable import context, main


def _get_addon_name(full_name: str) -> str:
Expand Down Expand Up @@ -53,6 +53,24 @@ def init_extendable_registry(cls):
extendable_registry.init_registry([f"odoo.addons.{current_addon}.*"])
cls.token = context.extendable_registry.set(cls._extendable_registry)

@classmethod
def backup_extendable_registry(cls):
# Store the current extendable classes
cls._initial_extendable_class_defs_by_module = (
main._extendable_class_defs_by_module
)
# Use a copy of the current extendable classes
main._extendable_class_defs_by_module = dict(
cls._initial_extendable_class_defs_by_module
)

@classmethod
def restore_extendable_registry(cls):
# Restore the initial extendable classes
main._extendable_class_defs_by_module = (
cls._initial_extendable_class_defs_by_module
)

@classmethod
def reset_extendable_registry(cls):
context.extendable_registry.reset(cls.token)
Loading