diff --git a/src/hope_dedup_engine/apps/faces/admin.py b/src/hope_dedup_engine/apps/faces/admin.py index f2aa8074..d845c120 100644 --- a/src/hope_dedup_engine/apps/faces/admin.py +++ b/src/hope_dedup_engine/apps/faces/admin.py @@ -6,7 +6,6 @@ @admin.register(TaskModel) class TaskModelAdmin(admin.ModelAdmin): - def has_add_permission(self, request: HttpRequest) -> bool: return False diff --git a/src/hope_dedup_engine/apps/security/models.py b/src/hope_dedup_engine/apps/security/models.py index e492f22e..5ff66739 100644 --- a/src/hope_dedup_engine/apps/security/models.py +++ b/src/hope_dedup_engine/apps/security/models.py @@ -9,7 +9,6 @@ class System(models.Model): class User(SecurityMixin, AbstractUser): - class Meta: abstract = False diff --git a/src/hope_dedup_engine/state.py b/src/hope_dedup_engine/state.py index c8d7f77b..0973df8f 100644 --- a/src/hope_dedup_engine/state.py +++ b/src/hope_dedup_engine/state.py @@ -3,14 +3,23 @@ from copy import copy from datetime import datetime, timedelta from threading import local -from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional +from typing import Any, Dict, Iterator, List, Mapping, Optional, Protocol +# TODO: find out what is correct value for this +not_set = None -not_set = object() + +class AnyRequest(Protocol): + COOKIES: Mapping[str, Any] + + +class AnyResponse(Protocol): + def set_cookie(self, name: str, *args: Any) -> None: + pass class State(local): - request: "AnyRequest|None" = None + request: AnyRequest | None = None cookies: Dict[str, List[Any]] = {} def __repr__(self) -> str: diff --git a/tests/extras/testutils/factories/__init__.py b/tests/extras/testutils/factories/__init__.py index 1595d1de..6cd5b3ca 100644 --- a/tests/extras/testutils/factories/__init__.py +++ b/tests/extras/testutils/factories/__init__.py @@ -8,7 +8,6 @@ def get_factory_for_model(_model) -> type[TAutoRegisterModelFactory]: - class Meta: model = _model diff --git a/tests/test_commands.py b/tests/test_commands.py index 551ef0a8..25d879fe 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -115,6 +115,7 @@ def test_env_raise(mocked_responses): with pytest.raises(CommandError): call_command("env", ignore_errors=False, check=True) + def test_upgrade_exception(mocked_responses, environment): with mock.patch("hope_dedup_engine.apps.core.management.commands.upgrade.call_command") as m: m.side_effect = Exception @@ -122,6 +123,6 @@ def test_upgrade_exception(mocked_responses, environment): call_command("upgrade") out = StringIO() - with mock.patch.dict(os.environ, {"ADMIN_EMAIL": "2222", "ADMIN_USER":"admin", **environment}, clear=True): + with mock.patch.dict(os.environ, {"ADMIN_EMAIL": "2222", "ADMIN_USER": "admin", **environment}, clear=True): with pytest.raises(SystemExit): call_command("upgrade", stdout=out, check=True, admin_email="")