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
6538e989
Commit
6538e989
authored
Sep 06, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some of the shopping cart tests.
parent
af2424da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
13 deletions
+21
-13
lms/djangoapps/shoppingcart/tests/test_models.py
+13
-7
lms/djangoapps/shoppingcart/tests/test_views.py
+8
-6
No files found.
lms/djangoapps/shoppingcart/tests/test_models.py
View file @
6538e989
...
...
@@ -20,10 +20,14 @@ from course_modes.models import CourseMode
from
shoppingcart.exceptions
import
PurchasedCallbackException
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
class
OrderTest
(
TestCase
):
def
setUp
(
self
):
self
.
user
=
UserFactory
.
create
()
self
.
course_id
=
"test/course"
self
.
course_id
=
"org/test/Test_Course"
CourseFactory
.
create
(
org
=
'org'
,
number
=
'test'
,
display_name
=
'Test Course 1'
)
for
i
in
xrange
(
1
,
5
):
CourseFactory
.
create
(
org
=
'org'
,
number
=
'test'
,
display_name
=
'Test Course {0}'
.
format
(
i
))
self
.
cost
=
40
def
test_get_cart_for_user
(
self
):
...
...
@@ -38,7 +42,7 @@ class OrderTest(TestCase):
def
test_cart_clear
(
self
):
cart
=
Order
.
get_cart_for_user
(
user
=
self
.
user
)
CertificateItem
.
add_to_order
(
cart
,
self
.
course_id
,
self
.
cost
,
'honor'
)
CertificateItem
.
add_to_order
(
cart
,
'
test/course
1'
,
self
.
cost
,
'honor'
)
CertificateItem
.
add_to_order
(
cart
,
'
org/test/Test_Course_
1'
,
self
.
cost
,
'honor'
)
self
.
assertEquals
(
cart
.
orderitem_set
.
count
(),
2
)
cart
.
clear
()
self
.
assertEquals
(
cart
.
orderitem_set
.
count
(),
0
)
...
...
@@ -58,10 +62,10 @@ class OrderTest(TestCase):
def
test_total_cost
(
self
):
cart
=
Order
.
get_cart_for_user
(
user
=
self
.
user
)
# add items to the order
course_costs
=
[(
'
test/course
1'
,
30
),
(
'
test/course
2'
,
40
),
(
'
test/course
3'
,
10
),
(
'
test/course
4'
,
20
)]
course_costs
=
[(
'
org/test/Test_Course_
1'
,
30
),
(
'
org/test/Test_Course_
2'
,
40
),
(
'
org/test/Test_Course_
3'
,
10
),
(
'
org/test/Test_Course_
4'
,
20
)]
for
course
,
cost
in
course_costs
:
CertificateItem
.
add_to_order
(
cart
,
course
,
cost
,
'honor'
)
self
.
assertEquals
(
cart
.
orderitem_set
.
count
(),
len
(
course_costs
))
...
...
@@ -225,13 +229,14 @@ class PaidCourseRegistrationTest(ModuleStoreTestCase):
self
.
assertFalse
(
CourseEnrollment
.
is_enrolled
(
self
.
user
,
self
.
course_id
))
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
class
CertificateItemTest
(
TestCase
):
"""
Tests for verifying specific CertificateItem functionality
"""
def
setUp
(
self
):
self
.
user
=
UserFactory
.
create
()
self
.
course_id
=
"
test/c
ourse"
self
.
course_id
=
"
org/test/Test_C
ourse"
self
.
cost
=
40
course_mode
=
CourseMode
(
course_id
=
self
.
course_id
,
mode_slug
=
"honor"
,
...
...
@@ -243,6 +248,7 @@ class CertificateItemTest(TestCase):
mode_display_name
=
"verified cert"
,
min_price
=
self
.
cost
)
course_mode
.
save
()
CourseFactory
.
create
(
org
=
'org'
,
number
=
'test'
,
run
=
'course'
,
display_name
=
'Test Course'
)
def
test_existing_enrollment
(
self
):
CourseEnrollment
.
enroll
(
self
.
user
,
self
.
course_id
)
...
...
lms/djangoapps/shoppingcart/tests/test_views.py
View file @
6538e989
...
...
@@ -50,6 +50,8 @@ class ShoppingCartViewsTests(ModuleStoreTestCase):
mode_display_name
=
"honor cert"
,
min_price
=
self
.
cost
)
self
.
course_mode
.
save
()
self
.
verified_course_id
=
'org/test/Test_Course'
CourseFactory
.
create
(
org
=
'org'
,
number
=
'test'
,
run
=
'course1'
,
display_name
=
'Test Course'
)
self
.
cart
=
Order
.
get_cart_for_user
(
self
.
user
)
def
login_user
(
self
):
...
...
@@ -91,7 +93,7 @@ class ShoppingCartViewsTests(ModuleStoreTestCase):
def
test_show_cart
(
self
):
self
.
login_user
()
reg_item
=
PaidCourseRegistration
.
add_to_order
(
self
.
cart
,
self
.
course_id
)
cert_item
=
CertificateItem
.
add_to_order
(
self
.
cart
,
'test/course1'
,
self
.
cost
,
'honor'
)
cert_item
=
CertificateItem
.
add_to_order
(
self
.
cart
,
self
.
verified_course_id
,
self
.
cost
,
'honor'
)
resp
=
self
.
client
.
get
(
reverse
(
'shoppingcart.views.show_cart'
,
args
=
[]))
self
.
assertEqual
(
resp
.
status_code
,
200
)
...
...
@@ -110,7 +112,7 @@ class ShoppingCartViewsTests(ModuleStoreTestCase):
def
test_clear_cart
(
self
):
self
.
login_user
()
PaidCourseRegistration
.
add_to_order
(
self
.
cart
,
self
.
course_id
)
CertificateItem
.
add_to_order
(
self
.
cart
,
'test/course1'
,
self
.
cost
,
'honor'
)
CertificateItem
.
add_to_order
(
self
.
cart
,
self
.
verified_course_id
,
self
.
cost
,
'honor'
)
self
.
assertEquals
(
self
.
cart
.
orderitem_set
.
count
(),
2
)
resp
=
self
.
client
.
post
(
reverse
(
'shoppingcart.views.clear_cart'
,
args
=
[]))
self
.
assertEqual
(
resp
.
status_code
,
200
)
...
...
@@ -120,7 +122,7 @@ class ShoppingCartViewsTests(ModuleStoreTestCase):
def
test_remove_item
(
self
,
exception_log
):
self
.
login_user
()
reg_item
=
PaidCourseRegistration
.
add_to_order
(
self
.
cart
,
self
.
course_id
)
cert_item
=
CertificateItem
.
add_to_order
(
self
.
cart
,
'test/course1'
,
self
.
cost
,
'honor'
)
cert_item
=
CertificateItem
.
add_to_order
(
self
.
cart
,
self
.
verified_course_id
,
self
.
cost
,
'honor'
)
self
.
assertEquals
(
self
.
cart
.
orderitem_set
.
count
(),
2
)
resp
=
self
.
client
.
post
(
reverse
(
'shoppingcart.views.remove_item'
,
args
=
[]),
{
'id'
:
reg_item
.
id
})
...
...
@@ -166,7 +168,7 @@ class ShoppingCartViewsTests(ModuleStoreTestCase):
def
test_show_receipt_404s
(
self
):
PaidCourseRegistration
.
add_to_order
(
self
.
cart
,
self
.
course_id
)
CertificateItem
.
add_to_order
(
self
.
cart
,
'test/course1'
,
self
.
cost
,
'honor'
)
CertificateItem
.
add_to_order
(
self
.
cart
,
self
.
verified_course_id
,
self
.
cost
,
'honor'
)
self
.
cart
.
purchase
()
user2
=
UserFactory
.
create
()
...
...
@@ -184,7 +186,7 @@ class ShoppingCartViewsTests(ModuleStoreTestCase):
@patch
(
'shoppingcart.views.render_to_response'
,
render_mock
)
def
test_show_receipt_success
(
self
):
reg_item
=
PaidCourseRegistration
.
add_to_order
(
self
.
cart
,
self
.
course_id
)
cert_item
=
CertificateItem
.
add_to_order
(
self
.
cart
,
'test/course1'
,
self
.
cost
,
'honor'
)
cert_item
=
CertificateItem
.
add_to_order
(
self
.
cart
,
self
.
verified_course_id
,
self
.
cost
,
'honor'
)
self
.
cart
.
purchase
(
first
=
'FirstNameTesting123'
,
street1
=
'StreetTesting123'
)
self
.
login_user
()
...
...
@@ -203,7 +205,7 @@ class ShoppingCartViewsTests(ModuleStoreTestCase):
@patch
(
'shoppingcart.views.render_to_response'
,
render_mock
)
def
test_show_receipt_success_refund
(
self
):
reg_item
=
PaidCourseRegistration
.
add_to_order
(
self
.
cart
,
self
.
course_id
)
cert_item
=
CertificateItem
.
add_to_order
(
self
.
cart
,
'test/course1'
,
self
.
cost
,
'honor'
)
cert_item
=
CertificateItem
.
add_to_order
(
self
.
cart
,
self
.
verified_course_id
,
self
.
cost
,
'honor'
)
self
.
cart
.
purchase
(
first
=
'FirstNameTesting123'
,
street1
=
'StreetTesting123'
)
cert_item
.
status
=
"refunded"
cert_item
.
save
()
...
...
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