From 8954d0748f8a1657482e40939a11d5a1c5e1a15a Mon Sep 17 00:00:00 2001 From: farhan Date: Wed, 4 Oct 2023 10:21:32 +0500 Subject: [PATCH] fix: Fix test cases --- openedx_learning/core/publishing/api.py | 2 +- .../core/tagging/models/system_defined.py | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/openedx_learning/core/publishing/api.py b/openedx_learning/core/publishing/api.py index 6a425b8c..b4b701a2 100644 --- a/openedx_learning/core/publishing/api.py +++ b/openedx_learning/core/publishing/api.py @@ -91,7 +91,7 @@ def create_publishable_entity_version( version_num=version_num, title=title, created=created, - created_by=created_by, + created_by_id=created_by, ) Draft.objects.create( entity_id=entity_id, diff --git a/openedx_tagging/core/tagging/models/system_defined.py b/openedx_tagging/core/tagging/models/system_defined.py index 23180f6e..6851ab9d 100644 --- a/openedx_tagging/core/tagging/models/system_defined.py +++ b/openedx_tagging/core/tagging/models/system_defined.py @@ -88,7 +88,10 @@ def validate_value(self, value: str): Check if 'value' is part of this Taxonomy, based on the specified model. """ try: - self.tag_class_model.objects.get(**{f"{self.tag_class_value_field}__iexact": value}) + # See https://github.com/typeddjango/django-stubs/issues/1684 for why we need to ignore this. + self.tag_class_model.objects.get( # type: ignore[attr-defined] + **{f"{self.tag_class_value_field}__iexact": value} + ) return True except ObjectDoesNotExist: return False @@ -100,7 +103,10 @@ def tag_for_value(self, value: str): try: # First we look up the instance by value. # We specify 'iexact' but whether it's case sensitive or not on MySQL depends on the model's collation. - instance = self.tag_class_model.objects.get(**{f"{self.tag_class_value_field}__iexact": value}) + # See https://github.com/typeddjango/django-stubs/issues/1684 for why we need to ignore this. + instance = self.tag_class_model.objects.get( # type: ignore[attr-defined] + **{f"{self.tag_class_value_field}__iexact": value} + ) except ObjectDoesNotExist as exc: raise Tag.DoesNotExist from exc # Use the canonical value from here on (possibly with different case from the value given as a parameter) @@ -120,7 +126,10 @@ def validate_external_id(self, external_id: str): Check if 'external_id' is part of this Taxonomy. """ try: - self.tag_class_model.objects.get(**{f"{self.tag_class_key_field}__iexact": external_id}) + # See https://github.com/typeddjango/django-stubs/issues/1684 for why we need to ignore this. + self.tag_class_model.objects.get( # type: ignore[attr-defined] + **{f"{self.tag_class_key_field}__iexact": external_id} + ) return True except ObjectDoesNotExist: return False @@ -136,7 +145,10 @@ def tag_for_external_id(self, external_id: str): try: # First we look up the instance by external_id # We specify 'iexact' but whether it's case sensitive or not on MySQL depends on the model's collation. - instance = self.tag_class_model.objects.get(**{f"{self.tag_class_key_field}__iexact": external_id}) + # See https://github.com/typeddjango/django-stubs/issues/1684 for why we need to ignore this. + instance = self.tag_class_model.objects.get( # type: ignore[attr-defined] + **{f"{self.tag_class_key_field}__iexact": external_id} + ) except ObjectDoesNotExist as exc: raise Tag.DoesNotExist from exc value = getattr(instance, self.tag_class_value_field)