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
d30974b5
Commit
d30974b5
authored
Jan 18, 2013
by
Brian Wilson
Committed by
Ashley Penney
Jan 24, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get pearson export working in a unit test
parent
7bcfc44b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
33 deletions
+62
-33
common/djangoapps/student/management/commands/pearson_export_cdd.py
+3
-2
common/djangoapps/student/management/commands/pearson_export_ead.py
+1
-0
common/djangoapps/student/management/commands/test/test_pearson.py
+54
-31
common/djangoapps/student/models.py
+4
-0
No files found.
common/djangoapps/student/management/commands/pearson_export_cdd.py
View file @
d30974b5
...
@@ -4,6 +4,7 @@ from collections import OrderedDict
...
@@ -4,6 +4,7 @@ from collections import OrderedDict
from
datetime
import
datetime
from
datetime
import
datetime
from
optparse
import
make_option
from
optparse
import
make_option
from
django.conf
import
settings
from
django.core.management.base
import
BaseCommand
from
django.core.management.base
import
BaseCommand
from
student.models
import
TestCenterUser
from
student.models
import
TestCenterUser
...
@@ -86,7 +87,7 @@ class Command(BaseCommand):
...
@@ -86,7 +87,7 @@ class Command(BaseCommand):
else
:
else
:
return
value
return
value
dump_all
=
options
[
'dump_all'
]
#
dump_all = options['dump_all']
with
open
(
destfile
,
"wb"
)
as
outfile
:
with
open
(
destfile
,
"wb"
)
as
outfile
:
writer
=
csv
.
DictWriter
(
outfile
,
writer
=
csv
.
DictWriter
(
outfile
,
...
@@ -96,7 +97,7 @@ class Command(BaseCommand):
...
@@ -96,7 +97,7 @@ class Command(BaseCommand):
extrasaction
=
'ignore'
)
extrasaction
=
'ignore'
)
writer
.
writeheader
()
writer
.
writeheader
()
for
tcu
in
TestCenterUser
.
objects
.
order_by
(
'id'
):
for
tcu
in
TestCenterUser
.
objects
.
order_by
(
'id'
):
if
dump_all
or
tcu
.
needs_uploading
:
if
tcu
.
needs_uploading
:
# or dump_all
record
=
dict
((
csv_field
,
ensure_encoding
(
getattr
(
tcu
,
model_field
)))
record
=
dict
((
csv_field
,
ensure_encoding
(
getattr
(
tcu
,
model_field
)))
for
csv_field
,
model_field
for
csv_field
,
model_field
in
Command
.
CSV_TO_MODEL_FIELDS
.
items
())
in
Command
.
CSV_TO_MODEL_FIELDS
.
items
())
...
...
common/djangoapps/student/management/commands/pearson_export_ead.py
View file @
d30974b5
...
@@ -4,6 +4,7 @@ from collections import OrderedDict
...
@@ -4,6 +4,7 @@ from collections import OrderedDict
from
datetime
import
datetime
from
datetime
import
datetime
from
optparse
import
make_option
from
optparse
import
make_option
from
django.conf
import
settings
from
django.core.management.base
import
BaseCommand
from
django.core.management.base
import
BaseCommand
from
student.models
import
TestCenterRegistration
from
student.models
import
TestCenterRegistration
...
...
common/djangoapps/student/management/commands/test/test_pearson.py
View file @
d30974b5
...
@@ -6,39 +6,18 @@ Created on Jan 17, 2013
...
@@ -6,39 +6,18 @@ Created on Jan 17, 2013
import
logging
import
logging
from
django.test
import
TestCase
from
django.test
import
TestCase
from
student.models
import
User
,
TestCenterRegistration
,
TestCenterUser
,
unique_id_for_user
from
student.models
import
User
,
TestCenterRegistration
,
TestCenterUser
from
mock
import
Mock
# This is stupid! Because I import a function with the word "test" in the name,
from
datetime
import
datetime
# the unittest framework tries to run *it* as a test?! Crazy!
from
student.models
import
get_testcenter_registration
as
get_tc_registration
from
django.core
import
management
from
django.core
import
management
COURSE_1
=
'edX/toy/2012_Fall'
COURSE_2
=
'edx/full/6.002_Spring_2012'
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
class
PearsonTestCase
(
TestCase
):
'''
Base class for tests running Pearson-related commands
'''
def
test_create_good_testcenter_user
(
self
):
username
=
"rusty"
# user = Mock(username=username)
# # id = unique_id_for_user(user)
# course = Mock(end_of_course_survey_url=survey_url)
newuser
=
User
.
objects
.
create_user
(
username
,
'rusty@edx.org'
,
'fakepass'
)
def
create_tc_user
(
username
):
# newuser.first_name='Rusty'
user
=
User
.
objects
.
create_user
(
username
,
'{}@edx.org'
.
format
(
username
),
'fakepass'
)
# newuser.last_name='Skids'
options
=
{
# newuser.is_staff=True
# newuser.is_active=True
# newuser.is_superuser=True
# newuser.last_login=datetime(2012, 1, 1)
# newuser.date_joined=datetime(2011, 1, 1)
# newuser.save(using='default')
options
=
{
'first_name'
:
'TestFirst'
,
'first_name'
:
'TestFirst'
,
'last_name'
:
'TestLast'
,
'last_name'
:
'TestLast'
,
'address_1'
:
'Test Address'
,
'address_1'
:
'Test Address'
,
...
@@ -49,5 +28,50 @@ class PearsonTestCase(TestCase):
...
@@ -49,5 +28,50 @@ class PearsonTestCase(TestCase):
'phone'
:
'252-1866'
,
'phone'
:
'252-1866'
,
'phone_country_code'
:
'1'
,
'phone_country_code'
:
'1'
,
}
}
management
.
call_command
(
'pearson_make_tc_user'
,
username
,
options
)
management
.
call_command
(
'pearson_make_tc_user'
,
username
,
**
options
)
return
TestCenterUser
.
objects
.
get
(
user
=
user
)
\ No newline at end of file
def
create_tc_registration
(
username
,
course_id
,
exam_code
,
accommodation_code
):
options
=
{
'exam_series_code'
:
exam_code
,
'eligibility_appointment_date_first'
:
'2013-01-01T00:00'
,
'eligibility_appointment_date_last'
:
'2013-12-31T23:59'
,
'accommodation_code'
:
accommodation_code
,
}
management
.
call_command
(
'pearson_make_tc_registration'
,
username
,
course_id
,
**
options
)
user
=
User
.
objects
.
get
(
username
=
username
)
registrations
=
get_tc_registration
(
user
,
course_id
,
exam_code
)
return
registrations
[
0
]
class
PearsonTestCase
(
TestCase
):
'''
Base class for tests running Pearson-related commands
'''
def
test_create_good_testcenter_user
(
self
):
testcenter_user
=
create_tc_user
(
"test1"
)
def
test_create_good_testcenter_registration
(
self
):
username
=
'test1'
course_id
=
'org1/course1/term1'
exam_code
=
'exam1'
accommodation_code
=
'NONE'
testcenter_user
=
create_tc_user
(
username
)
registration
=
create_tc_registration
(
username
,
course_id
,
exam_code
,
accommodation_code
)
def
test_export
(
self
):
username
=
'test1'
course_id
=
'org1/course1/term1'
exam_code
=
'exam1'
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'
:
output_dir
}):
management
.
call_command
(
'pearson_export_cdd'
,
**
options
)
management
.
call_command
(
'pearson_export_ead'
,
**
options
)
# TODO: check that files were output....
common/djangoapps/student/models.py
View file @
d30974b5
...
@@ -428,6 +428,10 @@ class TestCenterRegistration(models.Model):
...
@@ -428,6 +428,10 @@ class TestCenterRegistration(models.Model):
# TODO: figure out if this should really go in the database (with a default value).
# TODO: figure out if this should really go in the database (with a default value).
return
1
return
1
@property
def
needs_uploading
(
self
):
return
self
.
uploaded_at
is
None
or
self
.
uploaded_at
<
self
.
user_updated_at
@classmethod
@classmethod
def
create
(
cls
,
testcenter_user
,
exam
,
accommodation_request
):
def
create
(
cls
,
testcenter_user
,
exam
,
accommodation_request
):
registration
=
cls
(
testcenter_user
=
testcenter_user
)
registration
=
cls
(
testcenter_user
=
testcenter_user
)
...
...
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