This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| **/__pycache__/ | |
| **/.mypy_cache | |
| .pytest_cache | |
| **/.pytest_cache | |
| **/.tox | |
| **/.vscode | |
| **/.idea | |
| **/.coverage | |
| **/.DS_Store | |
| **/.eggs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @pytest.fixture() | |
| def patch_cls(monkeypatch): | |
| def do_patch_cls(cls: type, mock: Any = None): | |
| if mock is None: | |
| mock = MagicMock(spec=cls) | |
| def mock__new__(_cls, *_args, **_kwargs): | |
| return mock | |
| cls__new__ = cls.__new__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def select_fields_from_schema(schema: BaseModel, queryset: QuerySet, extend_include: list[str], exclude: list[str]): | |
| fields = set(schema.model_fields.keys()) | |
| if extend_include: | |
| fields = fields.union(extend_include) | |
| if exclude: | |
| fields = fields.difference(exclude) | |
| queryset_model_fields = [f.name for f in queryset.model._meta.get_fields() if f.concrete] | |
| fields = fields.intersection(queryset_model_fields) | |
| return queryset.values(*fields) |
OlderNewer