diff --git a/openedx_tagging/core/tagging/models/base.py b/openedx_tagging/core/tagging/models/base.py index 6ec2e3cd..f8246308 100644 --- a/openedx_tagging/core/tagging/models/base.py +++ b/openedx_tagging/core/tagging/models/base.py @@ -244,7 +244,7 @@ def cast(self): ) return self - + def check_casted(self): """ Double-check that this taxonomy has been cast() to a subclass if needed. @@ -524,7 +524,7 @@ def value(self, value: str): Stores to the _value field. """ self._value = value - + @property def is_deleted(self) -> bool: """ diff --git a/openedx_tagging/core/tagging/models/system_defined.py b/openedx_tagging/core/tagging/models/system_defined.py index c431e1c0..bcd90800 100644 --- a/openedx_tagging/core/tagging/models/system_defined.py +++ b/openedx_tagging/core/tagging/models/system_defined.py @@ -103,7 +103,7 @@ def tag_for_value(self, value: str): except ObjectDoesNotExist: raise Tag.DoesNotExist # Use the canonical value from here on (possibly with different case from the value given as a parameter) - value = getattr(instance, self.tag_class_value_field) + value = getattr(instance, self.tag_class_value_field) # We assume the value may change but the external_id is immutable. # So look up keys using external_id. There may be a key with the same external_id but an out of date value. external_id = str(getattr(instance, self.tag_class_key_field)) diff --git a/tests/openedx_tagging/core/tagging/test_api.py b/tests/openedx_tagging/core/tagging/test_api.py index 81c236a0..409e0933 100644 --- a/tests/openedx_tagging/core/tagging/test_api.py +++ b/tests/openedx_tagging/core/tagging/test_api.py @@ -257,9 +257,9 @@ def test_tag_object(self): # And the expected number of tags were returned assert len(object_tags) == len(tag_list) for index, object_tag in enumerate(object_tags): - assert object_tag.tag_id == tag_list[index].id - assert object_tag._value == tag_list[index].value object_tag.full_clean() # Should not raise any ValidationErrors + assert object_tag.tag_id == tag_list[index].id + assert object_tag._value == tag_list[index].value # pylint: disable=protected-access assert object_tag.taxonomy == self.taxonomy assert object_tag.name == self.taxonomy.name assert object_tag.object_id == "biology101" @@ -277,7 +277,7 @@ def test_tag_object_free_text(self): object_tag.full_clean() # Should not raise any ValidationErrors assert object_tag.taxonomy == self.taxonomy assert object_tag.name == self.taxonomy.name - assert object_tag._value == "Eukaryota Xenomorph" + assert object_tag._value == "Eukaryota Xenomorph" # pylint: disable=protected-access assert object_tag.get_lineage() == ["Eukaryota Xenomorph"] assert object_tag.object_id == "biology101" diff --git a/tests/openedx_tagging/core/tagging/test_models.py b/tests/openedx_tagging/core/tagging/test_models.py index c7825190..d34299e3 100644 --- a/tests/openedx_tagging/core/tagging/test_models.py +++ b/tests/openedx_tagging/core/tagging/test_models.py @@ -444,7 +444,7 @@ def test_clean(self): with pytest.raises(ValidationError): object_tag.full_clean() object_tag.tag = self.tag - object_tag._value = self.tag.value + object_tag._value = self.tag.value # pylint: disable=protected-access object_tag.full_clean() def test_tag_case(self) -> None: @@ -476,7 +476,7 @@ def test_tag_case(self) -> None: ).save() def test_is_deleted(self): - self.taxonomy.allow_multiple=True + self.taxonomy.allow_multiple = True self.taxonomy.save() open_taxonomy = Taxonomy.objects.create(name="Freetext Life", allow_free_text=True, allow_multiple=True) diff --git a/tests/openedx_tagging/core/tagging/test_system_defined_models.py b/tests/openedx_tagging/core/tagging/test_system_defined_models.py index 3026a844..c68144c4 100644 --- a/tests/openedx_tagging/core/tagging/test_system_defined_models.py +++ b/tests/openedx_tagging/core/tagging/test_system_defined_models.py @@ -34,21 +34,6 @@ class EmptyTestClass: """ -class InvalidModelTaxonomy(ModelSystemDefinedTaxonomy): - """ - Model used for testing - """ - - @property - def object_tag_class(self): - return EmptyTestClass - - class Meta: - proxy = True - managed = False - app_label = "oel_tagging" - - class TestLPTaxonomy(ModelSystemDefinedTaxonomy): """ Model used for testing - points to LearningPackage instances @@ -210,7 +195,7 @@ def test_tag_object_resync(self): api.tag_object(self.author_taxonomy, [self.user_1.username], object2_id) initial_object_tags = api.get_object_tags(object1_id) assert [t.value for t in initial_object_tags] == [self.user_1.username] - assert list(api.get_object_tags(other_obj_id)) == [] + assert not list(api.get_object_tags(other_obj_id)) # Change user_1's username: new_username = "new_username" self.user_1.username = new_username @@ -222,7 +207,7 @@ def test_tag_object_resync(self): # This is good - all the objects throughout the system with this tag now show the new value. assert [t.value for t in api.get_object_tags(object2_id)] == [new_username] # And just to make sure there are no other random changes to other objects: - assert list(api.get_object_tags(other_obj_id)) == [] + assert not list(api.get_object_tags(other_obj_id)) def test_tag_object_delete_user(self): """