Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump openedx-learning to support tagging with multiple taxonomies at once [FC-0036] #34490

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
TAXONOMY_ORG_LIST_URL = "/api/content_tagging/v1/taxonomies/"
TAXONOMY_ORG_DETAIL_URL = "/api/content_tagging/v1/taxonomies/{pk}/"
TAXONOMY_ORG_UPDATE_ORG_URL = "/api/content_tagging/v1/taxonomies/{pk}/orgs/"
OBJECT_TAG_UPDATE_URL = "/api/content_tagging/v1/object_tags/{object_id}/?taxonomy={taxonomy_id}"
OBJECT_TAG_UPDATE_URL = "/api/content_tagging/v1/object_tags/{object_id}/"
OBJECT_TAGS_EXPORT_URL = "/api/content_tagging/v1/object_tags/{object_id}/export/"
OBJECT_TAGS_URL = "/api/content_tagging/v1/object_tags/{object_id}/"
TAXONOMY_TEMPLATE_URL = "/api/content_tagging/v1/taxonomies/import/{filename}"
Expand Down Expand Up @@ -1404,6 +1404,13 @@ class TestObjectTagViewSet(TestObjectTagMixin, APITestCase):
Testing various cases for the ObjectTagView.
"""

def _call_put_request(self, object_id, taxonomy_id, tags):
url = OBJECT_TAG_UPDATE_URL.format(object_id=object_id)
return self.client.put(url, {"tagsData": [{
"taxonomy": taxonomy_id,
"tags": tags,
}]}, format="json")

@ddt.data(
# staffA and staff are staff in courseA and can tag using enabled taxonomies
("user", "tA1", ["Tag 1"], status.HTTP_403_FORBIDDEN),
Expand All @@ -1429,9 +1436,7 @@ def test_tag_course(self, user_attr, taxonomy_attr, tag_values, expected_status)

taxonomy = getattr(self, taxonomy_attr)

url = OBJECT_TAG_UPDATE_URL.format(object_id=self.courseA, taxonomy_id=taxonomy.pk)

response = self.client.put(url, {"tags": tag_values}, format="json")
response = self._call_put_request(self.courseA, taxonomy.pk, tag_values)

assert response.status_code == expected_status
if status.is_success(expected_status):
Expand All @@ -1445,6 +1450,7 @@ def test_tag_course(self, user_attr, taxonomy_attr, tag_values, expected_status)
assert tags_by_taxonomy == [] # No tags are set from any taxonomy

# Check that re-fetching the tags returns what we set
url = OBJECT_TAG_UPDATE_URL.format(object_id=self.courseA)
new_response = self.client.get(url, format="json")
assert status.is_success(new_response.status_code)
assert new_response.data == response.data
Expand All @@ -1463,8 +1469,7 @@ def test_tag_course_disabled_taxonomy(self, user_attr):
disabled_taxonomy = self.tA2
assert disabled_taxonomy.enabled is False

url = OBJECT_TAG_UPDATE_URL.format(object_id=self.courseA, taxonomy_id=disabled_taxonomy.pk)
response = self.client.put(url, {"tags": ["Tag 1"]}, format="json")
response = self._call_put_request(self.courseA, disabled_taxonomy.pk, ["Tag 1"])

assert response.status_code == status.HTTP_403_FORBIDDEN

Expand All @@ -1484,9 +1489,7 @@ def test_tag_course_invalid(self, user_attr, taxonomy_attr):

taxonomy = getattr(self, taxonomy_attr)

url = OBJECT_TAG_UPDATE_URL.format(object_id=self.courseA, taxonomy_id=taxonomy.pk)

response = self.client.put(url, {"tags": ["invalid"]}, format="json")
response = self._call_put_request(self.courseA, taxonomy.pk, ["invalid"])
assert response.status_code == status.HTTP_400_BAD_REQUEST

@ddt.data(
Expand All @@ -1513,9 +1516,7 @@ def test_tag_xblock(self, user_attr, taxonomy_attr, tag_values, expected_status)

taxonomy = getattr(self, taxonomy_attr)

url = OBJECT_TAG_UPDATE_URL.format(object_id=self.xblockA, taxonomy_id=taxonomy.pk)

response = self.client.put(url, {"tags": tag_values}, format="json")
response = self._call_put_request(self.xblockA, taxonomy.pk, tag_values)

assert response.status_code == expected_status
if status.is_success(expected_status):
Expand All @@ -1529,6 +1530,7 @@ def test_tag_xblock(self, user_attr, taxonomy_attr, tag_values, expected_status)
assert tags_by_taxonomy == [] # No tags are set from any taxonomy

# Check that re-fetching the tags returns what we set
url = OBJECT_TAG_UPDATE_URL.format(object_id=self.xblockA)
new_response = self.client.get(url, format="json")
assert status.is_success(new_response.status_code)
assert new_response.data == response.data
Expand All @@ -1547,8 +1549,7 @@ def test_tag_xblock_disabled_taxonomy(self, user_attr):
disabled_taxonomy = self.tA2
assert disabled_taxonomy.enabled is False

url = OBJECT_TAG_UPDATE_URL.format(object_id=self.xblockA, taxonomy_id=disabled_taxonomy.pk)
response = self.client.put(url, {"tags": ["Tag 1"]}, format="json")
response = self._call_put_request(self.xblockA, disabled_taxonomy.pk, ["Tag 1"])

assert response.status_code == status.HTTP_403_FORBIDDEN

Expand All @@ -1568,9 +1569,7 @@ def test_tag_xblock_invalid(self, user_attr, taxonomy_attr):

taxonomy = getattr(self, taxonomy_attr)

url = OBJECT_TAG_UPDATE_URL.format(object_id=self.xblockA, taxonomy_id=taxonomy.pk)

response = self.client.put(url, {"tags": ["invalid"]}, format="json")
response = self._call_put_request(self.xblockA, taxonomy.pk, ["invalid"])
assert response.status_code == status.HTTP_400_BAD_REQUEST

@ddt.data(
Expand Down Expand Up @@ -1598,9 +1597,7 @@ def test_tag_library(self, user_attr, taxonomy_attr, tag_values, expected_status

taxonomy = getattr(self, taxonomy_attr)

url = OBJECT_TAG_UPDATE_URL.format(object_id=self.libraryA, taxonomy_id=taxonomy.pk)

response = self.client.put(url, {"tags": tag_values}, format="json")
response = self._call_put_request(self.libraryA, taxonomy.pk, tag_values)

assert response.status_code == expected_status
if status.is_success(expected_status):
Expand All @@ -1614,6 +1611,7 @@ def test_tag_library(self, user_attr, taxonomy_attr, tag_values, expected_status
assert tags_by_taxonomy == [] # No tags are set from any taxonomy

# Check that re-fetching the tags returns what we set
url = OBJECT_TAG_UPDATE_URL.format(object_id=self.libraryA)
new_response = self.client.get(url, format="json")
assert status.is_success(new_response.status_code)
assert new_response.data == response.data
Expand All @@ -1632,8 +1630,7 @@ def test_tag_library_disabled_taxonomy(self, user_attr):
disabled_taxonomy = self.tA2
assert disabled_taxonomy.enabled is False

url = OBJECT_TAG_UPDATE_URL.format(object_id=self.libraryA, taxonomy_id=disabled_taxonomy.pk)
response = self.client.put(url, {"tags": ["Tag 1"]}, format="json")
response = self._call_put_request(self.libraryA, disabled_taxonomy.pk, ["Tag 1"])

assert response.status_code == status.HTTP_403_FORBIDDEN

Expand All @@ -1653,9 +1650,7 @@ def test_tag_library_invalid(self, user_attr, taxonomy_attr):

taxonomy = getattr(self, taxonomy_attr)

url = OBJECT_TAG_UPDATE_URL.format(object_id=self.libraryA, taxonomy_id=taxonomy.pk)

response = self.client.put(url, {"tags": ["invalid"]}, format="json")
response = self._call_put_request(self.libraryA, taxonomy.pk, ["invalid"])
assert response.status_code == status.HTTP_400_BAD_REQUEST

@ddt.data(
Expand All @@ -1672,9 +1667,7 @@ def test_tag_cross_org(self, user_attr, expected_status):
user = getattr(self, user_attr)
self.client.force_authenticate(user=user)

url = OBJECT_TAG_UPDATE_URL.format(object_id=self.courseB, taxonomy_id=self.tA1.pk)

response = self.client.put(url, {"tags": ["Tag 1"]}, format="json")
response = self._call_put_request(self.courseB, self.tA1.pk, ["Tag 1"])

assert response.status_code == expected_status

Expand All @@ -1692,9 +1685,7 @@ def test_tag_no_org(self, user_attr, expected_status):
user = getattr(self, user_attr)
self.client.force_authenticate(user=user)

url = OBJECT_TAG_UPDATE_URL.format(object_id=self.courseA, taxonomy_id=self.ot1.pk)

response = self.client.put(url, {"tags": []}, format="json")
response = self._call_put_request(self.courseA, self.ot1.pk, [])

assert response.status_code == expected_status

Expand All @@ -1709,9 +1700,7 @@ def test_tag_no_permission(self, objectid_attr):
self.client.force_authenticate(user=self.staffA)
object_id = getattr(self, objectid_attr)

url = OBJECT_TAG_UPDATE_URL.format(object_id=object_id, taxonomy_id=self.tA1.pk)

response = self.client.put(url, {"tags": ["Tag 1"]}, format="json")
response = self._call_put_request(object_id, self.tA1.pk, ["Tag 1"])

assert response.status_code == status.HTTP_403_FORBIDDEN

Expand All @@ -1725,20 +1714,17 @@ def test_tag_unauthorized(self, objectid_attr):
"""
object_id = getattr(self, objectid_attr)

url = OBJECT_TAG_UPDATE_URL.format(object_id=object_id, taxonomy_id=self.tA1.pk)

response = self.client.put(url, {"tags": ["Tag 1"]}, format="json")
response = self._call_put_request(object_id, self.tA1.pk, ["Tag 1"])

assert response.status_code == status.HTTP_401_UNAUTHORIZED

def test_tag_invalid_object(self):
"""
Test that we cannot tag an object that is not a CouseKey, LibraryLocatorV2 or UsageKey
"""
url = OBJECT_TAG_UPDATE_URL.format(object_id='invalid_key', taxonomy_id=self.tA1.pk)
self.client.force_authenticate(user=self.staff)

response = self.client.put(url, {"tags": ["Tag 1"]}, format="json")
response = self._call_put_request('invalid_key', self.tA1.pk, ["Tag 1"])

assert response.status_code == status.HTTP_403_FORBIDDEN

Expand All @@ -1749,10 +1735,9 @@ def test_get_tags(self):
self.client.force_authenticate(user=self.staffA)
taxonomy = self.multiple_taxonomy
tag_values = ["Tag 1", "Tag 2"]
put_url = OBJECT_TAG_UPDATE_URL.format(object_id=self.courseA, taxonomy_id=taxonomy.pk)

# Tag an object
response1 = self.client.put(put_url, {"tags": tag_values}, format="json")
response1 = self._call_put_request(self.courseA, taxonomy.pk, tag_values)
assert status.is_success(response1.status_code)

# Fetch this object's tags for a single taxonomy
Expand Down
2 changes: 1 addition & 1 deletion requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ libsass==0.10.0
click==8.1.6

# pinning this version to avoid updates while the library is being developed
openedx-learning==0.8.0
openedx-learning==0.9.1

# Open AI version 1.0.0 dropped support for openai.ChatCompletion which is currently in use in enterprise.
openai<=0.28.1
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ openedx-filters==1.6.0
# via
# -r requirements/edx/kernel.in
# lti-consumer-xblock
openedx-learning==0.8.0
openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3645-refined-drawer
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/kernel.in
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ openedx-filters==1.6.0
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
# lti-consumer-xblock
openedx-learning==0.8.0
openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3645-refined-drawer
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/doc.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ openedx-filters==1.6.0
# via
# -r requirements/edx/base.txt
# lti-consumer-xblock
openedx-learning==0.8.0
openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3645-refined-drawer
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/kernel.in
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,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-3645-refined-drawer#egg=openedx-learning # Open edX Learning core (experimental)
openedx-mongodbproxy
openedx-django-wiki
openedx-blockstore
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ openedx-filters==1.6.0
# via
# -r requirements/edx/base.txt
# lti-consumer-xblock
openedx-learning==0.8.0
openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@chris/FAL-3645-refined-drawer
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
Expand Down
Loading