Skip to content

Commit

Permalink
feat: add delete_object_tags function to oel_tagging api
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Aug 15, 2023
1 parent fb1fd08 commit 97e41d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions openedx_tagging/core/tagging/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ def get_object_tags(
yield object_tag


def delete_object_tags(object_id: str):
"""
Delete all ObjectTag entries for a given object.
"""
tags = (
ObjectTag.objects.filter(
object_id=object_id,
)
)

tags.delete()


def tag_object(
taxonomy: Taxonomy,
tags: List,
Expand Down
15 changes: 15 additions & 0 deletions tests/openedx_tagging/core/tagging/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,21 @@ def test_tag_object(self):
assert object_tag.name == self.taxonomy.name
assert object_tag.object_id == "biology101"

# Delete the tags
tagging_api.delete_object_tags("biology101")

# Ensure the tags were deleted
assert (
len(
list(
tagging_api.get_object_tags(
object_id="biology101",
)
)
)
== 0
)

def test_tag_object_free_text(self):
self.taxonomy.allow_free_text = True
self.taxonomy.save()
Expand Down

0 comments on commit 97e41d1

Please sign in to comment.