Skip to content

Commit

Permalink
style: Nits
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV committed Feb 1, 2024
1 parent 956ff96 commit f53025c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion openedx_tagging/core/tagging/rest_api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 3 additions & 5 deletions tests/openedx_tagging/core/tagging/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions tests/openedx_tagging/core/tagging/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"])
Expand Down
5 changes: 1 addition & 4 deletions tests/openedx_tagging/core/tagging/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f53025c

Please sign in to comment.