File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3939from gel ._internal import _dirhash
4040from gel ._internal import _import_extras
4141from gel ._internal ._codegen ._models import PydanticModelsGenerator
42+ from gel ._internal ._qbmodel ._pydantic ._models import GelModel
4243
4344from ._base import (
4445 AsyncQueryTestCase ,
7677if TYPE_CHECKING :
7778 from collections .abc import Callable , Iterator , Mapping , Sequence
7879 import pydantic
79- from gel ._internal ._qbmodel ._pydantic ._models import GelModel
8080
8181
8282_unset = object ()
@@ -533,6 +533,30 @@ def assertPydanticPickles(
533533 getattr (model2 , "__gel_changed_fields__" , ...),
534534 )
535535
536+ def _assertListEqualUnordered (
537+ self ,
538+ expected : list [Any ],
539+ actual : list [Any ],
540+ ) -> None :
541+ """Test that two collections have equal contents, though the order
542+ may be different.
543+
544+ Compares using the id of elements. Comparing lists of lists will not
545+ work.
546+ """
547+
548+ def key (value : Any ) -> Any :
549+ if isinstance (value , GelModel ) and (
550+ model_id := getattr (value , "id" , None )
551+ ):
552+ return model_id
553+ else :
554+ return id (value )
555+
556+ return self .assertEqual (
557+ sorted (expected , key = key ), sorted (actual , key = key )
558+ )
559+
536560 def _assertObjectsWithFields (
537561 self ,
538562 models : Collection [GelModel ],
You can’t perform that action at this time.
0 commit comments