Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
63a49d6d
Commit
63a49d6d
authored
Aug 20, 2015
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9398 from edx/release
Merge release into master
parents
987ca4b4
f17df2d0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
5 deletions
+26
-5
common/lib/xmodule/xmodule/partitions/partitions.py
+5
-1
common/lib/xmodule/xmodule/partitions/tests/test_partitions.py
+21
-4
No files found.
common/lib/xmodule/xmodule/partitions/partitions.py
View file @
63a49d6d
...
@@ -161,7 +161,11 @@ class UserPartition(namedtuple("UserPartition", "id name description groups sche
...
@@ -161,7 +161,11 @@ class UserPartition(namedtuple("UserPartition", "id name description groups sche
if
value
[
"version"
]
==
1
:
if
value
[
"version"
]
==
1
:
# If no scheme was provided, set it to the default ('random')
# If no scheme was provided, set it to the default ('random')
scheme_id
=
UserPartition
.
VERSION_1_SCHEME
scheme_id
=
UserPartition
.
VERSION_1_SCHEME
elif
value
[
"version"
]
==
UserPartition
.
VERSION
:
# Version changes should be backwards compatible in case the code
# gets rolled back. If we see a version number greater than the current
# version, we should try to read it rather than raising an exception.
elif
value
[
"version"
]
>=
UserPartition
.
VERSION
:
if
"scheme"
not
in
value
:
if
"scheme"
not
in
value
:
raise
TypeError
(
"UserPartition dict {0} missing value key 'scheme'"
.
format
(
value
))
raise
TypeError
(
"UserPartition dict {0} missing value key 'scheme'"
.
format
(
value
))
scheme_id
=
value
[
"scheme"
]
scheme_id
=
value
[
"scheme"
]
...
...
common/lib/xmodule/xmodule/partitions/tests/test_partitions.py
View file @
63a49d6d
...
@@ -60,7 +60,7 @@ class TestGroup(TestCase):
...
@@ -60,7 +60,7 @@ class TestGroup(TestCase):
jsonified
=
{
jsonified
=
{
"id"
:
test_id
,
"id"
:
test_id
,
"name"
:
name
,
"name"
:
name
,
"version"
:
9001
"version"
:
-
1
,
}
}
with
self
.
assertRaisesRegexp
(
TypeError
,
"has unexpected version"
):
with
self
.
assertRaisesRegexp
(
TypeError
,
"has unexpected version"
):
Group
.
from_json
(
jsonified
)
Group
.
from_json
(
jsonified
)
...
@@ -241,14 +241,13 @@ class TestUserPartition(PartitionTestCase):
...
@@ -241,14 +241,13 @@ class TestUserPartition(PartitionTestCase):
with
self
.
assertRaisesRegexp
(
UserPartitionError
,
"Unrecognized scheme"
):
with
self
.
assertRaisesRegexp
(
UserPartitionError
,
"Unrecognized scheme"
):
UserPartition
.
from_json
(
jsonified
)
UserPartition
.
from_json
(
jsonified
)
# Wrong version (it's over 9000!)
# Wrong version
# Wrong version (it's over 9000!)
jsonified
=
{
jsonified
=
{
'id'
:
self
.
TEST_ID
,
'id'
:
self
.
TEST_ID
,
"name"
:
self
.
TEST_NAME
,
"name"
:
self
.
TEST_NAME
,
"description"
:
self
.
TEST_DESCRIPTION
,
"description"
:
self
.
TEST_DESCRIPTION
,
"groups"
:
[
group
.
to_json
()
for
group
in
self
.
TEST_GROUPS
],
"groups"
:
[
group
.
to_json
()
for
group
in
self
.
TEST_GROUPS
],
"version"
:
900
1
,
"version"
:
-
1
,
"scheme"
:
self
.
TEST_SCHEME_NAME
,
"scheme"
:
self
.
TEST_SCHEME_NAME
,
}
}
with
self
.
assertRaisesRegexp
(
TypeError
,
"has unexpected version"
):
with
self
.
assertRaisesRegexp
(
TypeError
,
"has unexpected version"
):
...
@@ -284,6 +283,24 @@ class TestUserPartition(PartitionTestCase):
...
@@ -284,6 +283,24 @@ class TestUserPartition(PartitionTestCase):
with
self
.
assertRaises
(
NoSuchUserPartitionGroupError
):
with
self
.
assertRaises
(
NoSuchUserPartitionGroupError
):
self
.
user_partition
.
get_group
(
3
)
self
.
user_partition
.
get_group
(
3
)
def
test_forward_compatibility
(
self
):
# If the user partition version is updated in a release,
# then the release is rolled back, courses might contain
# version numbers greater than the currently deployed
# version number.
newer_version_json
=
{
"id"
:
self
.
TEST_ID
,
"name"
:
self
.
TEST_NAME
,
"description"
:
self
.
TEST_DESCRIPTION
,
"groups"
:
[
group
.
to_json
()
for
group
in
self
.
TEST_GROUPS
],
"version"
:
UserPartition
.
VERSION
+
1
,
"scheme"
:
"mock"
,
"additional_new_field"
:
"foo"
,
}
partition
=
UserPartition
.
from_json
(
newer_version_json
)
self
.
assertEqual
(
partition
.
id
,
self
.
TEST_ID
)
self
.
assertEqual
(
partition
.
name
,
self
.
TEST_NAME
)
class
StaticPartitionService
(
PartitionService
):
class
StaticPartitionService
(
PartitionService
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment