From 313122a33bdcdf0b70193fc8f2585dab898459ca Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Tue, 30 Jan 2024 10:02:36 -0500 Subject: [PATCH 1/6] feat: Export ID on Taxonomy --- .../core/djangoapps/content_tagging/api.py | 2 ++ .../content_tagging/tests/test_api.py | 21 +++++++++++++++---- .../content_tagging/tests/test_rules.py | 3 +++ requirements/constraints.txt | 2 +- requirements/edx/base.txt | 2 +- requirements/edx/development.txt | 2 +- requirements/edx/doc.txt | 2 +- requirements/edx/kernel.in | 2 +- requirements/edx/testing.txt | 2 +- 9 files changed, 28 insertions(+), 10 deletions(-) diff --git a/openedx/core/djangoapps/content_tagging/api.py b/openedx/core/djangoapps/content_tagging/api.py index 70aa7e2150da..05d75e50359c 100644 --- a/openedx/core/djangoapps/content_tagging/api.py +++ b/openedx/core/djangoapps/content_tagging/api.py @@ -14,6 +14,7 @@ def create_taxonomy( name: str, + export_id: str, description: str | None = None, enabled=True, allow_multiple=True, @@ -25,6 +26,7 @@ def create_taxonomy( """ taxonomy = oel_tagging.create_taxonomy( name=name, + export_id=export_id, description=description, enabled=enabled, allow_multiple=allow_multiple, diff --git a/openedx/core/djangoapps/content_tagging/tests/test_api.py b/openedx/core/djangoapps/content_tagging/tests/test_api.py index 9a297be968b1..4ea1224c60e4 100644 --- a/openedx/core/djangoapps/content_tagging/tests/test_api.py +++ b/openedx/core/djangoapps/content_tagging/tests/test_api.py @@ -20,22 +20,35 @@ def setUp(self): # Taxonomies self.taxonomy_disabled = api.create_taxonomy( name="Learning Objectives", + export_id="learning_objectives", # We will disable this taxonomy below, after we have used it to tag some objects. # Note: "disabled" taxonomies are not a supported nor user-exposed feature at the moment, so it's not # actually that important to test them. ) api.set_taxonomy_orgs(self.taxonomy_disabled, orgs=[self.org1, self.org2]) - self.taxonomy_all_orgs = api.create_taxonomy(name="Content Types") + self.taxonomy_all_orgs = api.create_taxonomy( + name="Content Types", + export_id="content_types", + ) api.set_taxonomy_orgs(self.taxonomy_all_orgs, all_orgs=True) - self.taxonomy_both_orgs = api.create_taxonomy(name="OpenedX/Axim Content Types") + self.taxonomy_both_orgs = api.create_taxonomy( + name="OpenedX/Axim Content Types", + export_id="axim_content_types", + ) api.set_taxonomy_orgs(self.taxonomy_both_orgs, orgs=[self.org1, self.org2]) - self.taxonomy_one_org = api.create_taxonomy(name="OpenedX Content Types") + self.taxonomy_one_org = api.create_taxonomy( + name="OpenedX Content Types", + export_id="openedx_content_types", + ) api.set_taxonomy_orgs(self.taxonomy_one_org, orgs=[self.org1]) - self.taxonomy_no_orgs = api.create_taxonomy(name="No orgs") + self.taxonomy_no_orgs = api.create_taxonomy( + name="No orgs", + export_id="no_orgs", + ) # Tags self.tag_disabled = Tag.objects.create( diff --git a/openedx/core/djangoapps/content_tagging/tests/test_rules.py b/openedx/core/djangoapps/content_tagging/tests/test_rules.py index d0aba1f91fb3..40d9516975f3 100644 --- a/openedx/core/djangoapps/content_tagging/tests/test_rules.py +++ b/openedx/core/djangoapps/content_tagging/tests/test_rules.py @@ -273,6 +273,7 @@ def test_system_taxonomy(self, perm): """ system_taxonomy = api.create_taxonomy( name="System Languages", + export_id="system_languages", ) system_taxonomy.taxonomy_class = UserSystemDefinedTaxonomy system_taxonomy = system_taxonomy.cast() @@ -436,6 +437,7 @@ def test_system_taxonomy_tag(self, perm): """ system_taxonomy = api.create_taxonomy( name="System Languages", + export_id="system_languages", ) system_taxonomy.taxonomy_class = UserSystemDefinedTaxonomy system_taxonomy = system_taxonomy.cast() @@ -460,6 +462,7 @@ def test_free_text_taxonomy_tag(self, perm): """ free_text_taxonomy = api.create_taxonomy( name="Free text", + export_id="free_text", allow_free_text=True, ) diff --git a/requirements/constraints.txt b/requirements/constraints.txt index dd88bbbd98d0..ce0c9184a27c 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -103,7 +103,7 @@ libsass==0.10.0 click==8.1.6 # pinning this version to avoid updates while the library is being developed -openedx-learning==0.4.4 +openedx-learning==0.5.0 # Open AI version 1.0.0 dropped support for openai.ChatCompletion which is currently in use in enterprise. openai<=0.28.1 diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index ba85aded42fb..3dd76d8946c8 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -780,7 +780,7 @@ openedx-filters==1.6.0 # via # -r requirements/edx/kernel.in # lti-consumer-xblock -openedx-learning==0.4.4 +openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3620-export-id-on-taxonomies # via # -c requirements/edx/../constraints.txt # -r requirements/edx/kernel.in diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 09bbb04832aa..41f406e2658f 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -1311,7 +1311,7 @@ openedx-filters==1.6.0 # -r requirements/edx/doc.txt # -r requirements/edx/testing.txt # lti-consumer-xblock -openedx-learning==0.4.4 +openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3620-export-id-on-taxonomies # via # -c requirements/edx/../constraints.txt # -r requirements/edx/doc.txt diff --git a/requirements/edx/doc.txt b/requirements/edx/doc.txt index f3a48ce4649e..0b0d3fe16254 100644 --- a/requirements/edx/doc.txt +++ b/requirements/edx/doc.txt @@ -922,7 +922,7 @@ openedx-filters==1.6.0 # via # -r requirements/edx/base.txt # lti-consumer-xblock -openedx-learning==0.4.4 +openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3620-export-id-on-taxonomies # via # -c requirements/edx/../constraints.txt # -r requirements/edx/base.txt diff --git a/requirements/edx/kernel.in b/requirements/edx/kernel.in index 3139561ff819..326136c319f9 100644 --- a/requirements/edx/kernel.in +++ b/requirements/edx/kernel.in @@ -117,7 +117,7 @@ openedx-calc # Library supporting mathematical calculatio openedx-django-require openedx-events # Open edX Events from Hooks Extension Framework (OEP-50) openedx-filters # Open edX Filters from Hooks Extension Framework (OEP-50) -openedx-learning # Open edX Learning core (experimental) +git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3620-export-id-on-taxonomies#egg=openedx-learning # Open edX Learning core (experimental) openedx-mongodbproxy openedx-django-wiki openedx-blockstore diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index f83a39fc217f..9ca6dba3b1bf 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -980,7 +980,7 @@ openedx-filters==1.6.0 # via # -r requirements/edx/base.txt # lti-consumer-xblock -openedx-learning==0.4.4 +openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3620-export-id-on-taxonomies # via # -c requirements/edx/../constraints.txt # -r requirements/edx/base.txt From bb1d9c401e144fcf55f7305feb3603ea8f3888a2 Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Tue, 30 Jan 2024 10:23:34 -0500 Subject: [PATCH 2/6] test: Fixing tests --- .../rest_api/v1/tests/test_views.py | 126 +++++++++++++++--- 1 file changed, 111 insertions(+), 15 deletions(-) diff --git a/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py b/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py index 20b1deb661b7..e590f7f5922d 100644 --- a/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py +++ b/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py @@ -174,11 +174,23 @@ def _setUp_taxonomies(self): Create taxonomies for testing """ # Orphaned taxonomy - self.ot1 = Taxonomy.objects.create(name="ot1", enabled=True) - self.ot2 = Taxonomy.objects.create(name="ot2", enabled=False) + self.ot1 = Taxonomy.objects.create( + name="ot1", + enabled=True, + export_id="ot1", + ) + self.ot2 = Taxonomy.objects.create( + name="ot2", + enabled=False, + export_id="ot2", + ) # System defined taxonomy - self.st1 = Taxonomy.objects.create(name="st1", enabled=True) + self.st1 = Taxonomy.objects.create( + name="st1", + enabled=True, + export_id="st1", + ) self.st1.taxonomy_class = SystemDefinedTaxonomy self.st1.save() TaxonomyOrg.objects.create( @@ -186,7 +198,11 @@ def _setUp_taxonomies(self): rel_type=TaxonomyOrg.RelType.OWNER, org=None, ) - self.st2 = Taxonomy.objects.create(name="st2", enabled=False) + self.st2 = Taxonomy.objects.create( + name="st2", + enabled=False, + export_id="st2", + ) self.st2.taxonomy_class = SystemDefinedTaxonomy self.st2.save() TaxonomyOrg.objects.create( @@ -195,12 +211,20 @@ def _setUp_taxonomies(self): ) # Global taxonomy, which contains tags - self.t1 = Taxonomy.objects.create(name="t1", enabled=True) + self.t1 = Taxonomy.objects.create( + name="t1", + enabled=True, + export_id="t1", + ) TaxonomyOrg.objects.create( taxonomy=self.t1, rel_type=TaxonomyOrg.RelType.OWNER, ) - self.t2 = Taxonomy.objects.create(name="t2", enabled=False) + self.t2 = Taxonomy.objects.create( + name="t2", + enabled=False, + export_id="t2", + ) TaxonomyOrg.objects.create( taxonomy=self.t2, rel_type=TaxonomyOrg.RelType.OWNER, @@ -213,11 +237,19 @@ def _setUp_taxonomies(self): Tag.objects.create(taxonomy=self.t1, value="anvil", parent=root1) # OrgA taxonomy - self.tA1 = Taxonomy.objects.create(name="tA1", enabled=True) + self.tA1 = Taxonomy.objects.create( + name="tA1", + enabled=True, + export_id="tA1", + ) TaxonomyOrg.objects.create( taxonomy=self.tA1, org=self.orgA, rel_type=TaxonomyOrg.RelType.OWNER,) - self.tA2 = Taxonomy.objects.create(name="tA2", enabled=False) + self.tA2 = Taxonomy.objects.create( + name="tA2", + enabled=False, + export_id="tA2", + ) TaxonomyOrg.objects.create( taxonomy=self.tA2, org=self.orgA, @@ -225,13 +257,21 @@ def _setUp_taxonomies(self): ) # OrgB taxonomy - self.tB1 = Taxonomy.objects.create(name="tB1", enabled=True) + self.tB1 = Taxonomy.objects.create( + name="tB1", + enabled=True, + export_id="tB1", + ) TaxonomyOrg.objects.create( taxonomy=self.tB1, org=self.orgB, rel_type=TaxonomyOrg.RelType.OWNER, ) - self.tB2 = Taxonomy.objects.create(name="tB2", enabled=False) + self.tB2 = Taxonomy.objects.create( + name="tB2", + enabled=False, + export_id="tB2", + ) TaxonomyOrg.objects.create( taxonomy=self.tB2, org=self.orgB, @@ -239,7 +279,11 @@ def _setUp_taxonomies(self): ) # OrgA and OrgB taxonomy - self.tBA1 = Taxonomy.objects.create(name="tBA1", enabled=True) + self.tBA1 = Taxonomy.objects.create( + name="tBA1", + enabled=True, + export_id="tBA1", + ) TaxonomyOrg.objects.create( taxonomy=self.tBA1, org=self.orgA, @@ -250,7 +294,11 @@ def _setUp_taxonomies(self): org=self.orgB, rel_type=TaxonomyOrg.RelType.OWNER, ) - self.tBA2 = Taxonomy.objects.create(name="tBA2", enabled=False) + self.tBA2 = Taxonomy.objects.create( + name="tBA2", + enabled=False, + export_id="tBA2", + ) TaxonomyOrg.objects.create( taxonomy=self.tBA2, org=self.orgA, @@ -466,6 +514,7 @@ def test_create_taxonomy(self, user_attr: str, expected_status: int) -> None: "description": "This is a description", "enabled": True, "allow_multiple": True, + "export_id": "taxonomy_data", } if user_attr: @@ -1327,8 +1376,16 @@ def setUp(self): block_id='block_id' ) - self.multiple_taxonomy = Taxonomy.objects.create(name="Multiple Taxonomy", allow_multiple=True) - self.single_value_taxonomy = Taxonomy.objects.create(name="Required Taxonomy", allow_multiple=False) + self.multiple_taxonomy = Taxonomy.objects.create( + name="Multiple Taxonomy", + allow_multiple=True, + export_id="multiple_taxonomy", + ) + self.single_value_taxonomy = Taxonomy.objects.create( + name="Required Taxonomy", + allow_multiple=False, + export_id="required_taxonomy", + ) for i in range(20): # Valid ObjectTags Tag.objects.create(taxonomy=self.tA1, value=f"Tag {i}") @@ -1336,7 +1393,11 @@ def setUp(self): Tag.objects.create(taxonomy=self.multiple_taxonomy, value=f"Tag {i}") Tag.objects.create(taxonomy=self.single_value_taxonomy, value=f"Tag {i}") - self.open_taxonomy = Taxonomy.objects.create(name="Enabled Free-Text Taxonomy", allow_free_text=True) + self.open_taxonomy = Taxonomy.objects.create( + name="Enabled Free-Text Taxonomy", + allow_free_text=True, + export_id="enabled_free_text_taxonomy", + ) # Add org permissions to taxonomy TaxonomyOrg.objects.create( @@ -1701,6 +1762,7 @@ def test_import_global_admin(self, file_format: str) -> None: { "taxonomy_name": "Imported Taxonomy name", "taxonomy_description": "Imported Taxonomy description", + "taxonomy_export_id": "imported_taxonomy", "file": file, }, format="multipart" @@ -1711,6 +1773,7 @@ def test_import_global_admin(self, file_format: str) -> None: taxonomy = response.data assert taxonomy["name"] == "Imported Taxonomy name" assert taxonomy["description"] == "Imported Taxonomy description" + assert taxonomy["export_id"] == "imported_taxonomy" # Check if the tags were created url = TAXONOMY_TAGS_URL.format(pk=taxonomy["id"]) @@ -1746,6 +1809,7 @@ def test_import_orgA_admin(self, file_format: str) -> None: { "taxonomy_name": "Imported Taxonomy name", "taxonomy_description": "Imported Taxonomy description", + "taxonomy_export_id": "imported_taxonomy", "file": file, }, format="multipart" @@ -1756,6 +1820,7 @@ def test_import_orgA_admin(self, file_format: str) -> None: taxonomy = response.data assert taxonomy["name"] == "Imported Taxonomy name" assert taxonomy["description"] == "Imported Taxonomy description" + assert taxonomy["export_id"] == "imported_taxonomy" # Check if the tags were created url = TAXONOMY_TAGS_URL.format(pk=taxonomy["id"]) @@ -1780,6 +1845,7 @@ def test_import_no_file(self) -> None: { "taxonomy_name": "Imported Taxonomy name", "taxonomy_description": "Imported Taxonomy description", + "taxonomy_export_id": "imported_taxonomy", }, format="multipart" ) @@ -1804,6 +1870,7 @@ def test_import_no_name(self, file_format) -> None: url, { "taxonomy_description": "Imported Taxonomy description", + "taxonomy_export_id": "imported_taxonomy", "file": file, }, format="multipart" @@ -1814,6 +1881,29 @@ def test_import_no_name(self, file_format) -> None: # Check if the taxonomy was not created assert not Taxonomy.objects.filter(name="Imported Taxonomy name").exists() + @ddt.data( + "csv", + "json", + ) + def test_import_no_export_id(self, file_format) -> None: + url = TAXONOMY_CREATE_IMPORT_URL + file = SimpleUploadedFile(f"taxonomy.{file_format}", b"invalid file content") + self.client.force_authenticate(user=self.staff) + response = self.client.post( + url, + { + "taxonomt_name": "Imported Taxonomy name", + "taxonomy_description": "Imported Taxonomy description", + "file": file, + }, + format="multipart" + ) + assert response.status_code == status.HTTP_400_BAD_REQUEST + assert response.data["taxonomy_export_id"][0] == "This field is required." + + # Check if the taxonomy was not created + assert not Taxonomy.objects.filter(name="Imported Taxonomy name").exists() + def test_import_invalid_format(self) -> None: """ Tests importing a taxonomy with an invalid file format. @@ -1826,6 +1916,7 @@ def test_import_invalid_format(self) -> None: { "taxonomy_name": "Imported Taxonomy name", "taxonomy_description": "Imported Taxonomy description", + "taxonomy_export_id": "imported_taxonomy_id", "file": file, }, format="multipart" @@ -1852,6 +1943,7 @@ def test_import_invalid_content(self, file_format) -> None: { "taxonomy_name": "Imported Taxonomy name", "taxonomy_description": "Imported Taxonomy description", + "taxonomy_export_id": "imported_taxonomy", "file": file, }, format="multipart" @@ -1881,6 +1973,7 @@ def test_import_no_perm(self) -> None: { "taxonomy_name": "Imported Taxonomy name", "taxonomy_description": "Imported Taxonomy description", + "taxonomy_export_id": "imported_taxonomy", "file": file, }, format="multipart" @@ -1902,6 +1995,7 @@ def setUp(self): self.taxonomy = Taxonomy.objects.create( name="Test import taxonomy", + export_id="test_import_taxonomy", ) tag_1 = Tag.objects.create( taxonomy=self.taxonomy, @@ -2009,6 +2103,7 @@ def test_import_invalid_content(self, file_format) -> None: { "taxonomy_name": "Imported Taxonomy name", "taxonomy_description": "Imported Taxonomy description", + "taxonomy_export_id": "imported_taxonomy", "file": file, }, format="multipart" @@ -2078,6 +2173,7 @@ def test_import_no_perm(self) -> None: { "taxonomy_name": "Imported Taxonomy name", "taxonomy_description": "Imported Taxonomy description", + "taxonomt_export_id": "imported_taxonomy", "file": file, }, format="multipart" From 8ab8321b9875677a2f60cfa3dcba275aee0ee7a3 Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Wed, 31 Jan 2024 12:11:14 -0500 Subject: [PATCH 3/6] refactor: Update export_id as optional in the API --- .../core/djangoapps/content_tagging/api.py | 4 ++-- .../rest_api/v1/tests/test_views.py | 4 ++++ .../content_tagging/tests/test_api.py | 21 ++++--------------- .../content_tagging/tests/test_rules.py | 5 +---- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/openedx/core/djangoapps/content_tagging/api.py b/openedx/core/djangoapps/content_tagging/api.py index 05d75e50359c..0df9e470035a 100644 --- a/openedx/core/djangoapps/content_tagging/api.py +++ b/openedx/core/djangoapps/content_tagging/api.py @@ -14,23 +14,23 @@ def create_taxonomy( name: str, - export_id: str, description: str | None = None, enabled=True, allow_multiple=True, allow_free_text=False, orgs: list[Organization] | None = None, + export_id: str | None = None, ) -> Taxonomy: """ Creates, saves, and returns a new Taxonomy with the given attributes. """ taxonomy = oel_tagging.create_taxonomy( name=name, - export_id=export_id, description=description, enabled=enabled, allow_multiple=allow_multiple, allow_free_text=allow_free_text, + export_id=export_id, ) if orgs is not None: diff --git a/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py b/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py index e590f7f5922d..82f51efaec60 100644 --- a/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py +++ b/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py @@ -62,6 +62,7 @@ def check_taxonomy( allow_free_text=False, system_defined=False, visible_to_authors=True, + export_id=None, **_ ): """ @@ -75,6 +76,7 @@ def check_taxonomy( assert data["allow_free_text"] == allow_free_text assert data["system_defined"] == system_defined assert data["visible_to_authors"] == visible_to_authors + assert data["export_id"] == export_id class TestTaxonomyObjectsMixin: @@ -1078,6 +1080,7 @@ def _test_api_call(self, **kwargs) -> None: "name": "new name", "description": taxonomy.description, "enabled": taxonomy.enabled, + "export_id": taxonomy.export_id, }, ) @@ -1118,6 +1121,7 @@ def _test_api_call(self, **kwargs) -> None: "name": "new name", "description": taxonomy.description, "enabled": taxonomy.enabled, + "export_id": taxonomy.export_id, }, ) diff --git a/openedx/core/djangoapps/content_tagging/tests/test_api.py b/openedx/core/djangoapps/content_tagging/tests/test_api.py index 4ea1224c60e4..9a297be968b1 100644 --- a/openedx/core/djangoapps/content_tagging/tests/test_api.py +++ b/openedx/core/djangoapps/content_tagging/tests/test_api.py @@ -20,35 +20,22 @@ def setUp(self): # Taxonomies self.taxonomy_disabled = api.create_taxonomy( name="Learning Objectives", - export_id="learning_objectives", # We will disable this taxonomy below, after we have used it to tag some objects. # Note: "disabled" taxonomies are not a supported nor user-exposed feature at the moment, so it's not # actually that important to test them. ) api.set_taxonomy_orgs(self.taxonomy_disabled, orgs=[self.org1, self.org2]) - self.taxonomy_all_orgs = api.create_taxonomy( - name="Content Types", - export_id="content_types", - ) + self.taxonomy_all_orgs = api.create_taxonomy(name="Content Types") api.set_taxonomy_orgs(self.taxonomy_all_orgs, all_orgs=True) - self.taxonomy_both_orgs = api.create_taxonomy( - name="OpenedX/Axim Content Types", - export_id="axim_content_types", - ) + self.taxonomy_both_orgs = api.create_taxonomy(name="OpenedX/Axim Content Types") api.set_taxonomy_orgs(self.taxonomy_both_orgs, orgs=[self.org1, self.org2]) - self.taxonomy_one_org = api.create_taxonomy( - name="OpenedX Content Types", - export_id="openedx_content_types", - ) + self.taxonomy_one_org = api.create_taxonomy(name="OpenedX Content Types") api.set_taxonomy_orgs(self.taxonomy_one_org, orgs=[self.org1]) - self.taxonomy_no_orgs = api.create_taxonomy( - name="No orgs", - export_id="no_orgs", - ) + self.taxonomy_no_orgs = api.create_taxonomy(name="No orgs") # Tags self.tag_disabled = Tag.objects.create( diff --git a/openedx/core/djangoapps/content_tagging/tests/test_rules.py b/openedx/core/djangoapps/content_tagging/tests/test_rules.py index 40d9516975f3..c104629ddb40 100644 --- a/openedx/core/djangoapps/content_tagging/tests/test_rules.py +++ b/openedx/core/djangoapps/content_tagging/tests/test_rules.py @@ -273,7 +273,6 @@ def test_system_taxonomy(self, perm): """ system_taxonomy = api.create_taxonomy( name="System Languages", - export_id="system_languages", ) system_taxonomy.taxonomy_class = UserSystemDefinedTaxonomy system_taxonomy = system_taxonomy.cast() @@ -437,7 +436,6 @@ def test_system_taxonomy_tag(self, perm): """ system_taxonomy = api.create_taxonomy( name="System Languages", - export_id="system_languages", ) system_taxonomy.taxonomy_class = UserSystemDefinedTaxonomy system_taxonomy = system_taxonomy.cast() @@ -461,8 +459,7 @@ def test_free_text_taxonomy_tag(self, perm): Test that even taxonomy administrators cannot edit/delete tags on free text taxonomies. """ free_text_taxonomy = api.create_taxonomy( - name="Free text", - export_id="free_text", + name="Free text", allow_free_text=True, ) From 458753ce4b4284593dcb8283fa0b210c1d9a31b0 Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Wed, 31 Jan 2024 13:17:02 -0500 Subject: [PATCH 4/6] style: Nits on lint --- openedx/core/djangoapps/content_tagging/tests/test_rules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/content_tagging/tests/test_rules.py b/openedx/core/djangoapps/content_tagging/tests/test_rules.py index c104629ddb40..d0aba1f91fb3 100644 --- a/openedx/core/djangoapps/content_tagging/tests/test_rules.py +++ b/openedx/core/djangoapps/content_tagging/tests/test_rules.py @@ -459,7 +459,7 @@ def test_free_text_taxonomy_tag(self, perm): Test that even taxonomy administrators cannot edit/delete tags on free text taxonomies. """ free_text_taxonomy = api.create_taxonomy( - name="Free text", + name="Free text", allow_free_text=True, ) From 92e022d2468e9edb5a82a425e6b22d365f32696e Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Thu, 1 Feb 2024 13:43:07 -0500 Subject: [PATCH 5/6] style: Use create_taxonomy api on tests --- .../rest_api/v1/tests/test_views.py | 84 ++++--------------- 1 file changed, 16 insertions(+), 68 deletions(-) diff --git a/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py b/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py index 82f51efaec60..f65be2cd8c16 100644 --- a/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py +++ b/openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py @@ -176,23 +176,11 @@ def _setUp_taxonomies(self): Create taxonomies for testing """ # Orphaned taxonomy - self.ot1 = Taxonomy.objects.create( - name="ot1", - enabled=True, - export_id="ot1", - ) - self.ot2 = Taxonomy.objects.create( - name="ot2", - enabled=False, - export_id="ot2", - ) + self.ot1 = tagging_api.create_taxonomy(name="ot1", enabled=True) + self.ot2 = tagging_api.create_taxonomy(name="ot2", enabled=False) # System defined taxonomy - self.st1 = Taxonomy.objects.create( - name="st1", - enabled=True, - export_id="st1", - ) + self.st1 = tagging_api.create_taxonomy(name="st1", enabled=True) self.st1.taxonomy_class = SystemDefinedTaxonomy self.st1.save() TaxonomyOrg.objects.create( @@ -200,11 +188,7 @@ def _setUp_taxonomies(self): rel_type=TaxonomyOrg.RelType.OWNER, org=None, ) - self.st2 = Taxonomy.objects.create( - name="st2", - enabled=False, - export_id="st2", - ) + self.st2 = tagging_api.create_taxonomy(name="st2", enabled=False) self.st2.taxonomy_class = SystemDefinedTaxonomy self.st2.save() TaxonomyOrg.objects.create( @@ -213,20 +197,12 @@ def _setUp_taxonomies(self): ) # Global taxonomy, which contains tags - self.t1 = Taxonomy.objects.create( - name="t1", - enabled=True, - export_id="t1", - ) + self.t1 = tagging_api.create_taxonomy(name="t1", enabled=True) TaxonomyOrg.objects.create( taxonomy=self.t1, rel_type=TaxonomyOrg.RelType.OWNER, ) - self.t2 = Taxonomy.objects.create( - name="t2", - enabled=False, - export_id="t2", - ) + self.t2 = tagging_api.create_taxonomy(name="t2", enabled=False) TaxonomyOrg.objects.create( taxonomy=self.t2, rel_type=TaxonomyOrg.RelType.OWNER, @@ -239,19 +215,11 @@ def _setUp_taxonomies(self): Tag.objects.create(taxonomy=self.t1, value="anvil", parent=root1) # OrgA taxonomy - self.tA1 = Taxonomy.objects.create( - name="tA1", - enabled=True, - export_id="tA1", - ) + self.tA1 = tagging_api.create_taxonomy(name="tA1", enabled=True) TaxonomyOrg.objects.create( taxonomy=self.tA1, org=self.orgA, rel_type=TaxonomyOrg.RelType.OWNER,) - self.tA2 = Taxonomy.objects.create( - name="tA2", - enabled=False, - export_id="tA2", - ) + self.tA2 = tagging_api.create_taxonomy(name="tA2", enabled=False) TaxonomyOrg.objects.create( taxonomy=self.tA2, org=self.orgA, @@ -259,21 +227,13 @@ def _setUp_taxonomies(self): ) # OrgB taxonomy - self.tB1 = Taxonomy.objects.create( - name="tB1", - enabled=True, - export_id="tB1", - ) + self.tB1 = tagging_api.create_taxonomy(name="tB1", enabled=True) TaxonomyOrg.objects.create( taxonomy=self.tB1, org=self.orgB, rel_type=TaxonomyOrg.RelType.OWNER, ) - self.tB2 = Taxonomy.objects.create( - name="tB2", - enabled=False, - export_id="tB2", - ) + self.tB2 = tagging_api.create_taxonomy(name="tB2", enabled=False) TaxonomyOrg.objects.create( taxonomy=self.tB2, org=self.orgB, @@ -281,11 +241,7 @@ def _setUp_taxonomies(self): ) # OrgA and OrgB taxonomy - self.tBA1 = Taxonomy.objects.create( - name="tBA1", - enabled=True, - export_id="tBA1", - ) + self.tBA1 = tagging_api.create_taxonomy(name="tBA1", enabled=True) TaxonomyOrg.objects.create( taxonomy=self.tBA1, org=self.orgA, @@ -296,11 +252,7 @@ def _setUp_taxonomies(self): org=self.orgB, rel_type=TaxonomyOrg.RelType.OWNER, ) - self.tBA2 = Taxonomy.objects.create( - name="tBA2", - enabled=False, - export_id="tBA2", - ) + self.tBA2 = tagging_api.create_taxonomy(name="tBA2", enabled=False) TaxonomyOrg.objects.create( taxonomy=self.tBA2, org=self.orgA, @@ -1380,15 +1332,13 @@ def setUp(self): block_id='block_id' ) - self.multiple_taxonomy = Taxonomy.objects.create( + self.multiple_taxonomy = tagging_api.create_taxonomy( name="Multiple Taxonomy", allow_multiple=True, - export_id="multiple_taxonomy", ) - self.single_value_taxonomy = Taxonomy.objects.create( + self.single_value_taxonomy = tagging_api.create_taxonomy( name="Required Taxonomy", allow_multiple=False, - export_id="required_taxonomy", ) for i in range(20): # Valid ObjectTags @@ -1397,10 +1347,9 @@ def setUp(self): Tag.objects.create(taxonomy=self.multiple_taxonomy, value=f"Tag {i}") Tag.objects.create(taxonomy=self.single_value_taxonomy, value=f"Tag {i}") - self.open_taxonomy = Taxonomy.objects.create( + self.open_taxonomy = tagging_api.create_taxonomy( name="Enabled Free-Text Taxonomy", allow_free_text=True, - export_id="enabled_free_text_taxonomy", ) # Add org permissions to taxonomy @@ -1997,9 +1946,8 @@ class TestImportTagsView(ImportTaxonomyMixin, APITestCase): def setUp(self): ImportTaxonomyMixin.setUp(self) - self.taxonomy = Taxonomy.objects.create( + self.taxonomy = tagging_api.create_taxonomy( name="Test import taxonomy", - export_id="test_import_taxonomy", ) tag_1 = Tag.objects.create( taxonomy=self.taxonomy, From 37bf598bfb75b9a8bc4cee02fc85533c17bb94a5 Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Fri, 2 Feb 2024 10:20:48 -0500 Subject: [PATCH 6/6] chore: Bump openedx-learning version --- requirements/constraints.txt | 2 +- requirements/edx/base.txt | 2 +- requirements/edx/development.txt | 2 +- requirements/edx/doc.txt | 2 +- requirements/edx/kernel.in | 2 +- requirements/edx/testing.txt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/requirements/constraints.txt b/requirements/constraints.txt index ed4f46dd7fae..3721c2fe9c38 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -103,7 +103,7 @@ libsass==0.10.0 click==8.1.6 # pinning this version to avoid updates while the library is being developed -openedx-learning==0.5.0 +openedx-learning==0.5.1 # Open AI version 1.0.0 dropped support for openai.ChatCompletion which is currently in use in enterprise. openai<=0.28.1 diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 821a88cf395f..f451e575374c 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -780,7 +780,7 @@ openedx-filters==1.6.0 # via # -r requirements/edx/kernel.in # lti-consumer-xblock -openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3620-export-id-on-taxonomies +openedx-learning==0.5.1 # via # -c requirements/edx/../constraints.txt # -r requirements/edx/kernel.in diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index e4634a79e48f..7a40601d267e 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -1311,7 +1311,7 @@ openedx-filters==1.6.0 # -r requirements/edx/doc.txt # -r requirements/edx/testing.txt # lti-consumer-xblock -openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3620-export-id-on-taxonomies +openedx-learning==0.5.1 # via # -c requirements/edx/../constraints.txt # -r requirements/edx/doc.txt diff --git a/requirements/edx/doc.txt b/requirements/edx/doc.txt index 8298313fadd3..dbffe87415ce 100644 --- a/requirements/edx/doc.txt +++ b/requirements/edx/doc.txt @@ -922,7 +922,7 @@ openedx-filters==1.6.0 # via # -r requirements/edx/base.txt # lti-consumer-xblock -openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3620-export-id-on-taxonomies +openedx-learning==0.5.1 # via # -c requirements/edx/../constraints.txt # -r requirements/edx/base.txt diff --git a/requirements/edx/kernel.in b/requirements/edx/kernel.in index 326136c319f9..3139561ff819 100644 --- a/requirements/edx/kernel.in +++ b/requirements/edx/kernel.in @@ -117,7 +117,7 @@ openedx-calc # Library supporting mathematical calculatio openedx-django-require openedx-events # Open edX Events from Hooks Extension Framework (OEP-50) openedx-filters # Open edX Filters from Hooks Extension Framework (OEP-50) -git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3620-export-id-on-taxonomies#egg=openedx-learning # Open edX Learning core (experimental) +openedx-learning # Open edX Learning core (experimental) openedx-mongodbproxy openedx-django-wiki openedx-blockstore diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index f093ce06e58b..b94f92e65e58 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -980,7 +980,7 @@ openedx-filters==1.6.0 # via # -r requirements/edx/base.txt # lti-consumer-xblock -openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3620-export-id-on-taxonomies +openedx-learning==0.5.1 # via # -c requirements/edx/../constraints.txt # -r requirements/edx/base.txt