Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
32 changes: 32 additions & 0 deletions contentcuration/contentcuration/tests/viewsets/test_contentnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,22 @@ def test_update_contentnode_tags(self):
.exists()
)

def test_update_contentnode_suggested_duration(self):
Comment thread
marcellamaki marked this conversation as resolved.
user = testdata.user()
contentnode = models.ContentNode.objects.create(**self.contentnode_db_metadata)
new_suggested_duration = 600

self.client.force_authenticate(user=user)
response = self.client.post(
self.sync_url,
[generate_update_event(contentnode.id, CONTENTNODE, {"suggested_duration": new_suggested_duration})],
format="json",
)
self.assertEqual(response.status_code, 200, response.content)
self.assertEqual(
models.ContentNode.objects.get(id=contentnode.id).suggested_duration, new_suggested_duration
)

def test_update_contentnode_tags_dont_duplicate(self):
user = testdata.user()
contentnode = models.ContentNode.objects.create(**self.contentnode_db_metadata)
Expand Down Expand Up @@ -1453,6 +1469,22 @@ def test_update_contentnode_tags(self):
.exists()
)

def test_update_contentnode_suggested_duration(self):
user = testdata.user()
contentnode = models.ContentNode.objects.create(**self.contentnode_db_metadata)
new_suggested_duration = 600

self.client.force_authenticate(user=user)
response = self.client.patch(
reverse("contentnode-detail", kwargs={"pk": contentnode.id}),
{"suggested_duration": new_suggested_duration},
format="json",
)
self.assertEqual(response.status_code, 200, response.content)
self.assertEqual(
models.ContentNode.objects.get(id=contentnode.id).suggested_duration, new_suggested_duration
)

def test_update_contentnode_tags_dont_duplicate(self):
user = testdata.user()
contentnode = models.ContentNode.objects.create(**self.contentnode_db_metadata)
Expand Down
2 changes: 2 additions & 0 deletions contentcuration/contentcuration/viewsets/contentnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ class Meta:
"accessibility_labels",
"categories",
"learner_needs",
"suggested_duration",
)
list_serializer_class = ContentNodeListSerializer
nested_writes = True
Expand Down Expand Up @@ -613,6 +614,7 @@ class ContentNodeViewSet(BulkUpdateMixin, ChangeEventMixin, ValuesViewset):
"accessibility_labels",
"categories",
"learner_needs",
"suggested_duration",
)

field_map = {
Expand Down