Skip to content

Commit 8d3a466

Browse files
authored
Merge pull request #3201 from rtibbles/ricecooker_tags
Fix tag assignment in ricecooker endpoints.
2 parents f4fc900 + 5c8058b commit 8d3a466

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

contentcuration/contentcuration/tests/test_chef_pipeline.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_authenticate_user_internal(self):
8888
response = self.post(self.authenticate_user_internal_url, None)
8989
assert response.status_code == 200
9090
data = json.loads(response.content)
91-
assert data["success"] == True
91+
assert data["success"]
9292
assert data["username"] == user().email
9393

9494
def test_check_version_bad_request(self):
@@ -184,6 +184,32 @@ def test_add_nodes(self):
184184
response.content
185185
)
186186

187+
def test_add_node_with_tags(self):
188+
response = self.post(
189+
self.create_channel_url, {"channel_data": channel_metadata}
190+
)
191+
assert response.status_code == 200
192+
data = json.loads(response.content)
193+
assert "root" in data
194+
195+
node_data = node_json(
196+
{"kind": "video", "license": cc.License.objects.all()[0].license_name}
197+
)
198+
unique_title = "This is a title that we can almost certainly find uniquely later"
199+
node_data["tags"] = ["test"]
200+
node_data["title"] = unique_title
201+
response = self.post(
202+
self.add_nodes_url, {"root_id": data["root"], "content_data": [node_data]}
203+
)
204+
assert response.status_code == 200, "Call failed:\n output: {}".format(
205+
response.content
206+
)
207+
208+
node = cc.ContentNode.objects.get(title=unique_title)
209+
210+
self.assertEqual(node.tags.count(), 1)
211+
self.assertEqual(node.tags.first().tag_name, "test")
212+
187213
def test_finish_channel_bad_request(self):
188214
response = self.post(self.finish_channel_url, {})
189215
assert response.status_code == 400

contentcuration/contentcuration/views/internal.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def api_commit_channel(request):
219219
event = generate_update_event(
220220
channel_id,
221221
CHANNEL,
222-
{"root_id": obj.main_tree.id, "staging_root_id": obj.staging_tree.id,},
222+
{"root_id": obj.main_tree.id, "staging_root_id": obj.staging_tree.id},
223223
)
224224

225225
# Mark old staging tree for garbage collection
@@ -441,7 +441,7 @@ def get_channel_status_bulk(request):
441441
raise PermissionDenied()
442442
statuses = {cid: get_status(cid) for cid in data['channel_ids']}
443443

444-
return Response({"success": True, "statuses": statuses,})
444+
return Response({"success": True, "statuses": statuses})
445445
except (Channel.DoesNotExist, PermissionDenied):
446446
return HttpResponseNotFound(
447447
"No complete set of channels matching: {}".format(",".join(channel_ids))
@@ -642,8 +642,7 @@ def create_node(node_data, parent_node, sort_order): # noqa: C901
642642
)
643643

644644
if len(tags) > 0:
645-
node.tags = tags
646-
node.save()
645+
node.tags.set(tags)
647646

648647
return node
649648

0 commit comments

Comments
 (0)