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
2f5ea630
Commit
2f5ea630
authored
Mar 06, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up courseware test_tabs unittests
parent
0d1b3800
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
96 deletions
+21
-96
lms/djangoapps/courseware/tests/test_tabs.py
+21
-96
No files found.
lms/djangoapps/courseware/tests/test_tabs.py
View file @
2f5ea630
from
django.test
import
TestCase
from
mock
import
patch
,
MagicMock
from
mock
import
MagicMock
import
courseware.tabs
as
tabs
from
courseware.access
import
has_access
from
django.test.utils
import
override_settings
from
collections
import
namedtuple
import
logging
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
fs.errors
import
ResourceNotFoundError
from
courseware.access
import
has_access
from
xmodule.error_module
import
ErrorDescriptor
from
xmodule.x_module
import
XModule
,
XModuleDescriptor
from
xmodule.modulestore
import
Location
###############################################################################
class
ProgressTestCase
(
TestCase
):
...
...
@@ -39,26 +24,20 @@ class ProgressTestCase(TestCase):
def
test_progress
(
self
):
self
.
assertEqual
(
tabs
.
_progress
(
self
.
tab
,
self
.
mockuser0
,
self
.
course
,
self
.
active_page0
),
[])
self
.
active_page0
),
[])
self
.
assertEqual
(
tabs
.
_progress
(
self
.
tab
,
self
.
mockuser1
,
self
.
course
,
self
.
active_page1
)[
0
]
.
name
,
'same'
)
self
.
active_page1
)[
0
]
.
name
,
'same'
)
self
.
assertEqual
(
tabs
.
_progress
(
self
.
tab
,
self
.
mockuser1
,
self
.
course
,
self
.
active_page1
)[
0
]
.
link
,
reverse
(
'progress'
,
args
=
[
self
.
course
.
id
]))
self
.
assertEqual
(
tabs
.
_progress
(
self
.
tab
,
self
.
mockuser1
,
self
.
course
,
self
.
active_page0
)[
0
]
.
is_active
,
False
)
self
.
active_page0
)[
0
]
.
is_active
,
False
)
self
.
assertEqual
(
tabs
.
_progress
(
self
.
tab
,
self
.
mockuser1
,
self
.
course
,
self
.
active_page1
)[
0
]
.
is_active
,
True
)
###############################################################################
self
.
active_page1
)[
0
]
.
is_active
,
True
)
class
WikiTestCase
(
TestCase
):
...
...
@@ -95,10 +74,7 @@ class WikiTestCase(TestCase):
def
test_wiki_enabled_false
(
self
):
self
.
assertEqual
(
tabs
.
_wiki
(
self
.
tab
,
self
.
user
,
self
.
course
,
self
.
active_page1
),
[])
###############################################################################
self
.
course
,
self
.
active_page1
),
[])
class
ExternalLinkTestCase
(
TestCase
):
...
...
@@ -129,8 +105,6 @@ class ExternalLinkTestCase(TestCase):
self
.
course
,
self
.
active_page00
)[
0
]
.
is_active
,
False
)
###############################################################################
class
StaticTabTestCase
(
TestCase
):
...
...
@@ -163,8 +137,6 @@ class StaticTabTestCase(TestCase):
self
.
course
,
self
.
active_page0
)[
0
]
.
is_active
,
False
)
###############################################################################
class
TextbooksTestCase
(
TestCase
):
...
...
@@ -230,39 +202,6 @@ class TextbooksTestCase(TestCase):
self
.
assertEqual
(
tabs
.
_textbooks
(
self
.
tab
,
self
.
mockuser0
,
self
.
course
,
self
.
active_pageX
),
[])
###############################################################################
#
#class StaffGradingTestCase(TestCase):
#
# def setUp(self):
#
# self.tab = MagicMock()
# self.user = MagicMock()
# self.course = MagicMock()
# self.active_page1 = 'staff_grading'
# self.activate_page0 = 'shadowfax'
# self.course.id = 'edX/full/6.002_Spring_2012'
# self.link = reverse('staff_grading', args = [self.course.id])
#
#
# def test_staff_grading(self):
#
# self.assertEqual(tabs._staff_grading(self.tab, self.user,
# self.course, self.active_page1)[0].name,
# 'Staff grading')
#
# self.assertEqual(tabs._staff_grading(self.tab, self.user,
# self.course, self.active_page1)[0].link,
# self.link)
#
# self.assertEqual(tabs._staff_grading(self.tab, self.user,
# self.course, self.active_page1)[0].is_active,
# True)
#
#
###############################################################################
class
KeyCheckerTestCase
(
TestCase
):
def
setUp
(
self
):
...
...
@@ -278,8 +217,6 @@ class KeyCheckerTestCase(TestCase):
tabs
.
key_checker
(
self
.
expected_keys0
),
self
.
dictio
)
###############################################################################
class
NullValidatorTestCase
(
TestCase
):
def
setUp
(
self
):
...
...
@@ -290,45 +227,33 @@ class NullValidatorTestCase(TestCase):
self
.
assertIsNone
(
tabs
.
null_validator
(
self
.
d
))
###############################################################################
class
ValidateTabsTestCase
(
TestCase
):
def
setUp
(
self
):
self
.
course0
=
MagicMock
()
self
.
course1
=
MagicMock
()
self
.
course2
=
MagicMock
()
self
.
course3
=
MagicMock
()
self
.
course4
=
MagicMock
()
self
.
course5
=
MagicMock
()
self
.
course0
.
tabs
=
None
self
.
course1
.
tabs
=
[{
'type'
:
'courseware'
},
{
'type'
:
'fax'
}]
self
.
course2
.
tabs
=
[{
'type'
:
'shadow'
},
{
'type'
:
'course_info'
}]
self
.
course3
.
tabs
=
[{
'type'
:
'set'
}]
self
.
course4
.
tabs
=
[{
'type'
:
'courseware'
},{
'type'
:
'course_info'
,
'name'
:
'alice'
},
self
.
courses
=
[
MagicMock
()
for
i
in
range
(
0
,
5
)]
self
.
courses
[
0
]
.
tabs
=
None
self
.
courses
[
1
]
.
tabs
=
[{
'type'
:
'courseware'
},
{
'type'
:
'fax'
}]
self
.
courses
[
2
]
.
tabs
=
[{
'type'
:
'shadow'
},
{
'type'
:
'course_info'
}]
self
.
courses
[
3
]
.
tabs
=
[{
'type'
:
'courseware'
},{
'type'
:
'course_info'
,
'name'
:
'alice'
},
{
'type'
:
'wiki'
,
'name'
:
'alice'
},
{
'type'
:
'discussion'
,
'name'
:
'alice'
},
{
'type'
:
'external_link'
,
'name'
:
'alice'
,
'link'
:
'blink'
},
{
'type'
:
'textbooks'
},
{
'type'
:
'progress'
,
'name'
:
'alice'
},
{
'type'
:
'static_tab'
,
'name'
:
'alice'
,
'url_slug'
:
'schlug'
},
{
'type'
:
'staff_grading'
}]
self
.
course
5
.
tabs
=
[{
'type'
:
'courseware'
},{
'type'
:
'course_info'
},
{
'type'
:
'flying'
}]
self
.
course
s
[
4
]
.
tabs
=
[{
'type'
:
'courseware'
},{
'type'
:
'course_info'
},
{
'type'
:
'flying'
}]
def
test_validate_tabs
(
self
):
self
.
assertIsNone
(
tabs
.
validate_tabs
(
self
.
course0
))
self
.
assertRaises
(
tabs
.
InvalidTabsException
,
tabs
.
validate_tabs
,
self
.
course3
)
self
.
assertRaises
(
tabs
.
InvalidTabsException
,
tabs
.
validate_tabs
,
self
.
course2
)
self
.
assertRaises
(
tabs
.
InvalidTabsException
,
tabs
.
validate_tabs
,
self
.
course1
)
self
.
assertRaises
(
tabs
.
InvalidTabsException
,
tabs
.
validate_tabs
,
self
.
course5
)
self
.
assertIsNone
(
tabs
.
validate_tabs
(
self
.
course4
))
self
.
assertRaises
(
tabs
.
InvalidTabsException
,
tabs
.
validate_tabs
,
self
.
course5
)
self
.
assertIsNone
(
tabs
.
validate_tabs
(
self
.
courses
[
0
]))
self
.
assertRaises
(
tabs
.
InvalidTabsException
,
tabs
.
validate_tabs
,
self
.
courses
[
1
])
self
.
assertRaises
(
tabs
.
InvalidTabsException
,
tabs
.
validate_tabs
,
self
.
courses
[
2
])
self
.
assertIsNone
(
tabs
.
validate_tabs
(
self
.
courses
[
3
]))
self
.
assertRaises
(
tabs
.
InvalidTabsException
,
tabs
.
validate_tabs
,
self
.
courses
[
4
])
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