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
1c4ffcf1
Commit
1c4ffcf1
authored
Mar 19, 2013
by
Jay Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix import statement for test.py
parent
daadaffb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
109 deletions
+2
-109
common/djangoapps/student/tests.py
+0
-107
common/djangoapps/student/tests/tests.py
+2
-2
No files found.
common/djangoapps/student/tests.py
deleted
100644 → 0
View file @
daadaffb
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
import
logging
from
django.test
import
TestCase
from
mock
import
Mock
from
.models
import
unique_id_for_user
from
.views
import
process_survey_link
,
_cert_info
COURSE_1
=
'edX/toy/2012_Fall'
COURSE_2
=
'edx/full/6.002_Spring_2012'
log
=
logging
.
getLogger
(
__name__
)
class
CourseEndingTest
(
TestCase
):
"""Test things related to course endings: certificates, surveys, etc"""
def
test_process_survey_link
(
self
):
username
=
"fred"
user
=
Mock
(
username
=
username
)
id
=
unique_id_for_user
(
user
)
link1
=
"http://www.mysurvey.com"
self
.
assertEqual
(
process_survey_link
(
link1
,
user
),
link1
)
link2
=
"http://www.mysurvey.com?unique={UNIQUE_ID}"
link2_expected
=
"http://www.mysurvey.com?unique={UNIQUE_ID}"
.
format
(
UNIQUE_ID
=
id
)
self
.
assertEqual
(
process_survey_link
(
link2
,
user
),
link2_expected
)
def
test_cert_info
(
self
):
user
=
Mock
(
username
=
"fred"
)
survey_url
=
"http://a_survey.com"
course
=
Mock
(
end_of_course_survey_url
=
survey_url
)
self
.
assertEqual
(
_cert_info
(
user
,
course
,
None
),
{
'status'
:
'processing'
,
'show_disabled_download_button'
:
False
,
'show_download_url'
:
False
,
'show_survey_button'
:
False
,
})
cert_status
=
{
'status'
:
'unavailable'
}
self
.
assertEqual
(
_cert_info
(
user
,
course
,
cert_status
),
{
'status'
:
'processing'
,
'show_disabled_download_button'
:
False
,
'show_download_url'
:
False
,
'show_survey_button'
:
False
})
cert_status
=
{
'status'
:
'generating'
,
'grade'
:
'67'
}
self
.
assertEqual
(
_cert_info
(
user
,
course
,
cert_status
),
{
'status'
:
'generating'
,
'show_disabled_download_button'
:
True
,
'show_download_url'
:
False
,
'show_survey_button'
:
True
,
'survey_url'
:
survey_url
,
'grade'
:
'67'
})
cert_status
=
{
'status'
:
'regenerating'
,
'grade'
:
'67'
}
self
.
assertEqual
(
_cert_info
(
user
,
course
,
cert_status
),
{
'status'
:
'generating'
,
'show_disabled_download_button'
:
True
,
'show_download_url'
:
False
,
'show_survey_button'
:
True
,
'survey_url'
:
survey_url
,
'grade'
:
'67'
})
download_url
=
'http://s3.edx/cert'
cert_status
=
{
'status'
:
'downloadable'
,
'grade'
:
'67'
,
'download_url'
:
download_url
}
self
.
assertEqual
(
_cert_info
(
user
,
course
,
cert_status
),
{
'status'
:
'ready'
,
'show_disabled_download_button'
:
False
,
'show_download_url'
:
True
,
'download_url'
:
download_url
,
'show_survey_button'
:
True
,
'survey_url'
:
survey_url
,
'grade'
:
'67'
})
cert_status
=
{
'status'
:
'notpassing'
,
'grade'
:
'67'
,
'download_url'
:
download_url
}
self
.
assertEqual
(
_cert_info
(
user
,
course
,
cert_status
),
{
'status'
:
'notpassing'
,
'show_disabled_download_button'
:
False
,
'show_download_url'
:
False
,
'show_survey_button'
:
True
,
'survey_url'
:
survey_url
,
'grade'
:
'67'
})
# Test a course that doesn't have a survey specified
course2
=
Mock
(
end_of_course_survey_url
=
None
)
cert_status
=
{
'status'
:
'notpassing'
,
'grade'
:
'67'
,
'download_url'
:
download_url
}
self
.
assertEqual
(
_cert_info
(
user
,
course2
,
cert_status
),
{
'status'
:
'notpassing'
,
'show_disabled_download_button'
:
False
,
'show_download_url'
:
False
,
'show_survey_button'
:
False
,
'grade'
:
'67'
})
common/djangoapps/student/tests/tests.py
View file @
1c4ffcf1
...
...
@@ -9,8 +9,8 @@ import logging
from
django.test
import
TestCase
from
mock
import
Mock
from
.models
import
unique_id_for_user
from
.views
import
process_survey_link
,
_cert_info
from
student
.models
import
unique_id_for_user
from
student
.views
import
process_survey_link
,
_cert_info
COURSE_1
=
'edX/toy/2012_Fall'
COURSE_2
=
'edx/full/6.002_Spring_2012'
...
...
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