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
28 changes: 27 additions & 1 deletion contentcuration/contentcuration/tests/test_chef_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_authenticate_user_internal(self):
response = self.post(self.authenticate_user_internal_url, None)
assert response.status_code == 200
data = json.loads(response.content)
assert data["success"] == True
assert data["success"]
assert data["username"] == user().email

def test_check_version_bad_request(self):
Expand Down Expand Up @@ -184,6 +184,32 @@ def test_add_nodes(self):
response.content
)

def test_add_node_with_tags(self):
response = self.post(
self.create_channel_url, {"channel_data": channel_metadata}
)
assert response.status_code == 200
data = json.loads(response.content)
assert "root" in data

node_data = node_json(
{"kind": "video", "license": cc.License.objects.all()[0].license_name}
)
unique_title = "This is a title that we can almost certainly find uniquely later"
node_data["tags"] = ["test"]
node_data["title"] = unique_title
response = self.post(
self.add_nodes_url, {"root_id": data["root"], "content_data": [node_data]}
)
assert response.status_code == 200, "Call failed:\n output: {}".format(
response.content
)

node = cc.ContentNode.objects.get(title=unique_title)

self.assertEqual(node.tags.count(), 1)
self.assertEqual(node.tags.first().tag_name, "test")

def test_finish_channel_bad_request(self):
response = self.post(self.finish_channel_url, {})
assert response.status_code == 400
Expand Down
7 changes: 3 additions & 4 deletions contentcuration/contentcuration/views/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def api_commit_channel(request):
event = generate_update_event(
channel_id,
CHANNEL,
{"root_id": obj.main_tree.id, "staging_root_id": obj.staging_tree.id,},
{"root_id": obj.main_tree.id, "staging_root_id": obj.staging_tree.id},
)

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

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

if len(tags) > 0:
node.tags = tags
node.save()
node.tags.set(tags)

return node

Expand Down