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
f4703b40
Commit
f4703b40
authored
Jan 18, 2013
by
Brian Wilson
Committed by
Ashley Penney
Jan 24, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test-with-settings
parent
553528cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
7 deletions
+47
-7
common/djangoapps/student/management/commands/tests/test_pearson.py
+47
-7
No files found.
common/djangoapps/student/management/commands/tests/test_pearson.py
View file @
f4703b40
...
...
@@ -4,14 +4,16 @@ Created on Jan 17, 2013
@author: brian
'''
import
logging
import
os
from
tempfile
import
mkdtemp
import
cStringIO
import
sys
from
django.test
import
TestCase
from
student.models
import
User
,
TestCenterRegistration
,
TestCenterUser
# This is stupid! Because I import a function with the word "test" in the name,
# the unittest framework tries to run *it* as a test?! Crazy!
from
student.models
import
get_tc_registration
from
django.core
import
management
from
student.models
import
User
,
TestCenterRegistration
,
TestCenterUser
,
get_tc_registration
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -49,7 +51,40 @@ class PearsonTestCase(TestCase):
'''
Base class for tests running Pearson-related commands
'''
import_dir
=
mkdtemp
(
prefix
=
"import"
)
export_dir
=
mkdtemp
(
prefix
=
"export"
)
def
tearDown
(
self
):
def
delete_temp_dir
(
dirname
):
if
os
.
path
.
exists
(
dirname
):
for
filename
in
os
.
listdir
(
dirname
):
os
.
remove
(
os
.
path
.
join
(
dirname
,
filename
))
os
.
rmdir
(
dirname
)
# clean up after any test data was dumped to temp directory
delete_temp_dir
(
self
.
import_dir
)
delete_temp_dir
(
self
.
export_dir
)
def
test_missing_demographic_fields
(
self
):
old_stdout
=
sys
.
stdout
sys
.
stdout
=
cStringIO
.
StringIO
()
username
=
'baduser'
User
.
objects
.
create_user
(
username
,
'{}@edx.org'
.
format
(
username
),
'fakepass'
)
options
=
{}
self
.
assertRaises
(
BaseException
,
management
.
call_command
,
'pearson_make_tc_user'
,
username
,
**
options
)
output_string
=
sys
.
stdout
.
getvalue
()
self
.
assertTrue
(
output_string
.
find
(
'Field Form errors encountered:'
)
>=
0
)
self
.
assertTrue
(
output_string
.
find
(
'Field Form Error: city'
)
>=
0
)
self
.
assertTrue
(
output_string
.
find
(
'Field Form Error: first_name'
)
>=
0
)
self
.
assertTrue
(
output_string
.
find
(
'Field Form Error: last_name'
)
>=
0
)
self
.
assertTrue
(
output_string
.
find
(
'Field Form Error: country'
)
>=
0
)
self
.
assertTrue
(
output_string
.
find
(
'Field Form Error: phone_country_code'
)
>=
0
)
self
.
assertTrue
(
output_string
.
find
(
'Field Form Error: phone'
)
>=
0
)
self
.
assertTrue
(
output_string
.
find
(
'Field Form Error: address_1'
)
>=
0
)
sys
.
stdout
=
old_stdout
def
test_create_good_testcenter_user
(
self
):
testcenter_user
=
create_tc_user
(
"test1"
)
...
...
@@ -68,10 +103,15 @@ class PearsonTestCase(TestCase):
accommodation_code
=
'NONE'
testcenter_user
=
create_tc_user
(
username
)
registration
=
create_tc_registration
(
username
,
course_id
,
exam_code
,
accommodation_code
)
output_dir
=
"./tmpOutput"
options
=
{
'
destination'
:
output_dir
}
with
self
.
settings
(
PEARSON
=
{
'LOCAL_EXPORT'
:
outpu
t_dir
}):
#options = { 'destination' : self.export_dir }
options
=
{
'
--dest-from-settings'
:
None
}
with
self
.
settings
(
PEARSON
=
{
'LOCAL_EXPORT'
:
self
.
expor
t_dir
}):
management
.
call_command
(
'pearson_export_cdd'
,
**
options
)
print
'Files found: {}'
.
format
(
os
.
listdir
(
self
.
export_dir
))
self
.
assertEquals
(
len
(
os
.
listdir
(
self
.
export_dir
)),
1
,
"Expect cdd file to be created"
)
management
.
call_command
(
'pearson_export_ead'
,
**
options
)
print
'Files found: {}'
.
format
(
os
.
listdir
(
self
.
export_dir
))
self
.
assertEquals
(
len
(
os
.
listdir
(
self
.
export_dir
)),
2
,
"Expect ead file to also be created"
)
# TODO: check that files were output....
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