Skip to content

Commit 1e7a670

Browse files
authored
Merge pull request #203 from akolson/add-channel-version
Adds the channel_version field to the embed_content_request schema
2 parents 427a6dd + 81e204e commit 1e7a670

6 files changed

Lines changed: 53 additions & 5 deletions

File tree

js/EmbedContentRequest.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,19 @@ export const SCHEMA = {
118118
"content_id": {
119119
"$ref": "#/definitions/uuid",
120120
"description": "The UUID of the content resource(s)"
121+
},
122+
"channel_version": {
123+
"type": "integer",
124+
"description": "The version number of the channel that the content resource belongs to"
121125
}
122126
},
123127
"required": [
124128
"id",
125129
"channel_id",
126130
"title",
127131
"description",
128-
"content_id"
132+
"content_id",
133+
"channel_version"
129134
]
130135
}
131136
},

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
"scripts": {
2828
"test": "echo \"Error: no test specified\" && exit 1"
2929
},
30-
"version": "0.2.14"
30+
"version": "0.2.15"
3131
}

le_utils/constants/embed_content_request.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,19 @@
112112
"$ref": "#/definitions/uuid",
113113
"description": "The UUID of the content resource(s)",
114114
},
115+
"channel_version": {
116+
"type": "integer",
117+
"description": "The version number of the channel that the content resource belongs to",
118+
},
115119
},
116-
"required": ["id", "channel_id", "title", "description", "content_id"],
120+
"required": [
121+
"id",
122+
"channel_id",
123+
"title",
124+
"description",
125+
"content_id",
126+
"channel_version",
127+
],
117128
},
118129
},
119130
"properties": {

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
setup(
99
name="le-utils",
1010
packages=find_packages(),
11-
version="0.2.14",
11+
version="0.2.15",
1212
description="LE-Utils contains shared constants used in Kolibri, Ricecooker, and Kolibri Studio.",
1313
long_description=long_description,
1414
long_description_content_type="text/markdown",

spec/schema-embed_content_request.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,19 @@
113113
"content_id": {
114114
"$ref": "#/definitions/uuid",
115115
"description": "The UUID of the content resource(s)"
116+
},
117+
"channel_version": {
118+
"type": "integer",
119+
"description": "The version number of the channel that the content resource belongs to"
116120
}
117121
},
118122
"required": [
119123
"id",
120124
"channel_id",
121125
"title",
122126
"description",
123-
"content_id"
127+
"content_id",
128+
"channel_version"
124129
]
125130
}
126131
},

tests/test_schemas.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ def test_embed__content__valid():
493493
"text": "Resource text",
494494
"language": "en",
495495
"content_id": str(uuid.uuid4()),
496+
"channel_version": 1,
496497
},
497498
],
498499
"metadata": {
@@ -517,6 +518,7 @@ def test_embed__content__valid_with_files():
517518
"text": "Resource text",
518519
"language": "en",
519520
"content_id": str(uuid.uuid4()),
521+
"channel_version": 1,
520522
"files": [
521523
{
522524
"url": "http://localhost:8000/media/1234.jpg",
@@ -616,6 +618,31 @@ def test_embed__content__invalid_content_id():
616618
)
617619

618620

621+
@skip_if_jsonschema_unavailable
622+
def test_embed__content__invalid_channel_version():
623+
with pytest.raises(jsonschema.ValidationError):
624+
_validate_embed_content_request(
625+
{
626+
"resources": [
627+
{
628+
"id": str(uuid.uuid4()),
629+
"channel_id": str(uuid.uuid4()),
630+
"title": "Resource title",
631+
"description": "Resource description",
632+
"text": "Resource text",
633+
"language": "en",
634+
"content_id": str(uuid.uuid4()),
635+
"channel_version": "v1",
636+
},
637+
],
638+
"metadata": {
639+
"channel_title": "Channel title",
640+
"some_additional_field": "some_random_value",
641+
},
642+
}
643+
)
644+
645+
619646
@skip_if_jsonschema_unavailable
620647
def test_embed__content__invalid_url_files():
621648
with pytest.raises(jsonschema.ValidationError):

0 commit comments

Comments
 (0)