Skip to content

Commit

Permalink
fix: Fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan committed Oct 4, 2023
1 parent a1cc499 commit 8954d07
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion openedx_learning/core/publishing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 16 additions & 4 deletions openedx_tagging/core/tagging/models/system_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 8954d07

Please sign in to comment.