From f53025c0f6868443006abdc7a55ccd2a65149d1a Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Thu, 1 Feb 2024 13:08:14 -0500 Subject: [PATCH] style: Nits --- openedx_tagging/core/tagging/rest_api/v1/views.py | 2 +- tests/openedx_tagging/core/tagging/test_api.py | 8 +++----- tests/openedx_tagging/core/tagging/test_models.py | 7 +++---- tests/openedx_tagging/core/tagging/test_views.py | 5 +---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/openedx_tagging/core/tagging/rest_api/v1/views.py b/openedx_tagging/core/tagging/rest_api/v1/views.py index acb45fa0..5eed0e5a 100644 --- a/openedx_tagging/core/tagging/rest_api/v1/views.py +++ b/openedx_tagging/core/tagging/rest_api/v1/views.py @@ -58,7 +58,7 @@ class TaxonomyView(ModelViewSet): """ View to list, create, retrieve, update, delete, export or import Taxonomies. - TODO: We need to add a perform_udate and call the api update function when is created. + TODO: We need to add a perform_update and call the api update function when is created. This is because it is necessary to call the model validations. (`full_clean()`). Currently those validations are not run, which means we could update `export_id` with any value through this api. diff --git a/tests/openedx_tagging/core/tagging/test_api.py b/tests/openedx_tagging/core/tagging/test_api.py index 73b82bc9..9cfeec37 100644 --- a/tests/openedx_tagging/core/tagging/test_api.py +++ b/tests/openedx_tagging/core/tagging/test_api.py @@ -253,10 +253,9 @@ def test_get_children_tags_invalid_taxonomy(self) -> None: """ Calling get_children_tags on free text taxonomies gives an error. """ - free_text_taxonomy = Taxonomy.objects.create( - allow_free_text=True, + free_text_taxonomy = tagging_api.create_taxonomy( name="FreeText", - export_id="free_text" + allow_free_text=True, ) tagging_api.tag_object(object_id="obj1", taxonomy=free_text_taxonomy, tags=["some_tag"]) with self.assertRaises(ValueError) as exc: @@ -272,11 +271,10 @@ def test_get_children_tags_no_children(self) -> None: def test_resync_object_tags(self) -> None: self.taxonomy.allow_multiple = True self.taxonomy.save() - open_taxonomy = Taxonomy.objects.create( + open_taxonomy = tagging_api.create_taxonomy( name="Freetext Life", allow_free_text=True, allow_multiple=True, - export_id='freetext_life', ) object_id = "obj1" diff --git a/tests/openedx_tagging/core/tagging/test_models.py b/tests/openedx_tagging/core/tagging/test_models.py index 90427702..303e7e5f 100644 --- a/tests/openedx_tagging/core/tagging/test_models.py +++ b/tests/openedx_tagging/core/tagging/test_models.py @@ -38,7 +38,7 @@ def setUp(self): self.system_taxonomy = Taxonomy.objects.get(name="System defined taxonomy") self.language_taxonomy = LanguageTaxonomy.objects.get(name="Languages") self.user_taxonomy = Taxonomy.objects.get(name="User Authors").cast() - self.free_text_taxonomy = Taxonomy.objects.create(name="Free Text", allow_free_text=True) + self.free_text_taxonomy = api.create_taxonomy(name="Free Text", allow_free_text=True) # References to some tags: self.archaea = get_tag("Archaea") @@ -111,11 +111,10 @@ def create_100_taxonomies(self): """ dummy_taxonomies = [] for i in range(100): - taxonomy = Taxonomy.objects.create( + taxonomy = api.create_taxonomy( name=f"ZZ Dummy Taxonomy {i:03}", allow_free_text=True, allow_multiple=True, - export_id=f"zz_dummy_taxonomy_{i:03}" ) ObjectTag.objects.create( object_id="limit_tag_count", @@ -602,7 +601,7 @@ class TestFilteredTagsFreeTextTaxonomy(TestCase): def setUp(self): super().setUp() - self.taxonomy = Taxonomy.objects.create(allow_free_text=True, name="FreeText") + self.taxonomy = api.create_taxonomy(allow_free_text=True, name="FreeText") # The "triple" tag will be applied to three objects, "double" to two, and "solo" to one: api.tag_object(object_id="obj1", taxonomy=self.taxonomy, tags=["triple"]) api.tag_object(object_id="obj2", taxonomy=self.taxonomy, tags=["triple", "double"]) diff --git a/tests/openedx_tagging/core/tagging/test_views.py b/tests/openedx_tagging/core/tagging/test_views.py index 82c43dc9..d29f56fd 100644 --- a/tests/openedx_tagging/core/tagging/test_views.py +++ b/tests/openedx_tagging/core/tagging/test_views.py @@ -2544,10 +2544,7 @@ def _check_taxonomy_not_changed(self) -> None: def setUp(self): ImportTaxonomyMixin.setUp(self) - self.taxonomy = Taxonomy.objects.create( - name="Test import taxonomy", - export_id="test_import_taxonomy", - ) + self.taxonomy = api.create_taxonomy(name="Test import taxonomy") tag_1 = Tag.objects.create( taxonomy=self.taxonomy, external_id="old_tag_1",