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
9f3bad67
Commit
9f3bad67
authored
Apr 11, 2013
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the license test over to CourseFactory
parent
13a48507
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
lms/djangoapps/licenses/tests.py
+13
-5
No files found.
lms/djangoapps/licenses/tests.py
View file @
9f3bad67
...
...
@@ -8,10 +8,14 @@ from tempfile import NamedTemporaryFile
from
factory
import
Factory
,
SubFactory
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
django.core.management
import
call_command
from
django.core.urlresolvers
import
reverse
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
licenses.models
import
CourseSoftware
,
UserLicense
from
courseware.tests.tests
import
LoginEnrollmentTestCase
,
get_user
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
COURSE_1
=
'edX/toy/2012_Fall'
...
...
@@ -130,20 +134,24 @@ class LicenseTestCase(LoginEnrollmentTestCase):
self
.
assertEqual
(
302
,
response
.
status_code
)
class
CommandTest
(
TestCase
):
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
class
CommandTest
(
ModuleStoreTestCase
):
'''Test management command for importing serial numbers'''
def
setUp
(
self
):
course
=
CourseFactory
.
create
()
self
.
course_id
=
course
.
id
def
test_import_serial_numbers
(
self
):
size
=
20
log
.
debug
(
'Adding one set of serials for {0}'
.
format
(
SOFTWARE_1
))
with
generate_serials_file
(
size
)
as
temp_file
:
args
=
[
COURSE_1
,
SOFTWARE_1
,
temp_file
.
name
]
args
=
[
self
.
course_id
,
SOFTWARE_1
,
temp_file
.
name
]
call_command
(
'import_serial_numbers'
,
*
args
)
log
.
debug
(
'Adding one set of serials for {0}'
.
format
(
SOFTWARE_2
))
with
generate_serials_file
(
size
)
as
temp_file
:
args
=
[
COURSE_1
,
SOFTWARE_2
,
temp_file
.
name
]
args
=
[
self
.
course_id
,
SOFTWARE_2
,
temp_file
.
name
]
call_command
(
'import_serial_numbers'
,
*
args
)
log
.
debug
(
'There should be only 2 course-software entries'
)
...
...
@@ -156,7 +164,7 @@ class CommandTest(TestCase):
log
.
debug
(
'Adding more serial numbers to {0}'
.
format
(
SOFTWARE_1
))
with
generate_serials_file
(
size
)
as
temp_file
:
args
=
[
COURSE_1
,
SOFTWARE_1
,
temp_file
.
name
]
args
=
[
self
.
course_id
,
SOFTWARE_1
,
temp_file
.
name
]
call_command
(
'import_serial_numbers'
,
*
args
)
log
.
debug
(
'There should be still only 2 course-software entries'
)
...
...
@@ -179,7 +187,7 @@ class CommandTest(TestCase):
with
NamedTemporaryFile
()
as
tmpfile
:
tmpfile
.
write
(
'
\n
'
.
join
(
known_serials
))
tmpfile
.
flush
()
args
=
[
COURSE_1
,
SOFTWARE_1
,
tmpfile
.
name
]
args
=
[
self
.
course_id
,
SOFTWARE_1
,
tmpfile
.
name
]
call_command
(
'import_serial_numbers'
,
*
args
)
log
.
debug
(
'Check if we added only the new ones'
)
...
...
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