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
87557a1a
Commit
87557a1a
authored
Jun 09, 2014
by
Calen Pennington
Committed by
Sarina Canelake
Jun 09, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests of RoleCache
parent
2757ac4f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
3 deletions
+42
-3
common/djangoapps/student/tests/test_roles.py
+42
-3
No files found.
common/djangoapps/student/tests/test_roles.py
View file @
87557a1a
"""
"""
Tests of student.roles
Tests of student.roles
"""
"""
import
ddt
from
django.test
import
TestCase
from
django.test
import
TestCase
from
courseware.tests.factories
import
UserFactory
,
StaffFactory
,
InstructorFactory
from
courseware.tests.factories
import
UserFactory
,
StaffFactory
,
InstructorFactory
from
student.tests.factories
import
AnonymousUserFactory
from
student.tests.factories
import
AnonymousUserFactory
from
student.roles
import
GlobalStaff
,
CourseRole
,
CourseStaffRole
,
OrgStaffRole
,
OrgInstructorRole
,
\
from
student.roles
import
(
CourseInstructorRole
GlobalStaff
,
CourseRole
,
CourseStaffRole
,
CourseInstructorRole
,
OrgStaffRole
,
OrgInstructorRole
,
RoleCache
,
CourseBetaTesterRole
)
from
xmodule.modulestore.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.locations
import
SlashSeparatedCourseKey
...
@@ -152,3 +154,40 @@ class RolesTestCase(TestCase):
...
@@ -152,3 +154,40 @@ class RolesTestCase(TestCase):
role
.
add_users
(
self
.
student
)
role
.
add_users
(
self
.
student
)
role
.
remove_users
(
self
.
student
)
role
.
remove_users
(
self
.
student
)
self
.
assertFalse
(
role
.
has_user
(
self
.
student
))
self
.
assertFalse
(
role
.
has_user
(
self
.
student
))
@ddt.ddt
class
RoleCacheTestCase
(
TestCase
):
IN_KEY
=
SlashSeparatedCourseKey
(
'edX'
,
'toy'
,
'2012_Fall'
)
NOT_IN_KEY
=
SlashSeparatedCourseKey
(
'edX'
,
'toy'
,
'2013_Fall'
)
ROLES
=
(
(
CourseStaffRole
(
IN_KEY
),
(
'staff'
,
IN_KEY
,
'edX'
)),
(
CourseInstructorRole
(
IN_KEY
),
(
'instructor'
,
IN_KEY
,
'edX'
)),
(
OrgStaffRole
(
IN_KEY
.
org
),
(
'staff'
,
None
,
'edX'
)),
(
OrgInstructorRole
(
IN_KEY
.
org
),
(
'instructor'
,
None
,
'edX'
)),
(
CourseBetaTesterRole
(
IN_KEY
),
(
'beta_testers'
,
IN_KEY
,
'edX'
)),
)
def
setUp
(
self
):
self
.
user
=
UserFactory
()
@ddt.data
(
*
ROLES
)
@ddt.unpack
def
test_only_in_role
(
self
,
role
,
target
):
role
.
add_users
(
self
.
user
)
cache
=
RoleCache
(
self
.
user
)
self
.
assertTrue
(
cache
.
has_role
(
*
target
))
for
other_role
,
other_target
in
self
.
ROLES
:
if
other_role
==
role
:
continue
self
.
assertFalse
(
cache
.
has_role
(
*
other_target
))
@ddt.data
(
*
ROLES
)
@ddt.unpack
def
test_empty_cache
(
self
,
role
,
target
):
cache
=
RoleCache
(
self
.
user
)
self
.
assertFalse
(
cache
.
has_role
(
*
target
))
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