Commit 569727e6 by Diana Huang

Pep8 fixes

parent d7e311f5
...@@ -217,8 +217,8 @@ class CourseFields(object): ...@@ -217,8 +217,8 @@ class CourseFields(object):
has_children = True has_children = True
checklists = List(scope=Scope.settings, checklists = List(scope=Scope.settings,
default=[ default=[
{"short_description" : "Getting Started With Studio", {"short_description": "Getting Started With Studio",
"items" : [{"short_description": "Add Course Team Members", "items": [{"short_description": "Add Course Team Members",
"long_description": "Grant your collaborators permission to edit your course so you can work together.", "long_description": "Grant your collaborators permission to edit your course so you can work together.",
"is_checked": False, "is_checked": False,
"action_url": "ManageUsers", "action_url": "ManageUsers",
...@@ -241,10 +241,9 @@ class CourseFields(object): ...@@ -241,10 +241,9 @@ class CourseFields(object):
"is_checked": False, "is_checked": False,
"action_url": "", "action_url": "",
"action_text": "", "action_text": "",
"action_external": False}] "action_external": False}]},
}, {"short_description": "Draft a Rough Course Outline",
{"short_description" : "Draft a Rough Course Outline", "items": [{"short_description": "Create Your First Section and Subsection",
"items" : [{"short_description": "Create Your First Section and Subsection",
"long_description": "Use your course outline to build your first Section and Subsection.", "long_description": "Use your course outline to build your first Section and Subsection.",
"is_checked": False, "is_checked": False,
"action_url": "CourseOutline", "action_url": "CourseOutline",
...@@ -285,10 +284,9 @@ class CourseFields(object): ...@@ -285,10 +284,9 @@ class CourseFields(object):
"is_checked": False, "is_checked": False,
"action_url": "CourseOutline", "action_url": "CourseOutline",
"action_text": "Edit Course Outline", "action_text": "Edit Course Outline",
"action_external": False}] "action_external": False}]},
}, {"short_description": "Explore edX's Support Tools",
{"short_description" : "Explore edX's Support Tools", "items": [{"short_description": "Explore the Studio Help Forum",
"items" : [{"short_description": "Explore the Studio Help Forum",
"long_description": "Access the Studio Help forum from the menu that appears when you click your user name in the top right corner of Studio.", "long_description": "Access the Studio Help forum from the menu that appears when you click your user name in the top right corner of Studio.",
"is_checked": False, "is_checked": False,
"action_url": "http://help.edge.edx.org/", "action_url": "http://help.edge.edx.org/",
...@@ -305,10 +303,9 @@ class CourseFields(object): ...@@ -305,10 +303,9 @@ class CourseFields(object):
"is_checked": False, "is_checked": False,
"action_url": "http://files.edx.org/Getting_Started_with_Studio.pdf", "action_url": "http://files.edx.org/Getting_Started_with_Studio.pdf",
"action_text": "Download Documentation", "action_text": "Download Documentation",
"action_external": True}] "action_external": True}]},
}, {"short_description": "Draft Your Course About Page",
{"short_description" : "Draft Your Course About Page", "items": [{"short_description": "Draft a Course Description",
"items" : [{"short_description": "Draft a Course Description",
"long_description": "Courses on edX have an About page that includes a course video, description, and more. Draft the text students will read before deciding to enroll in your course.", "long_description": "Courses on edX have an About page that includes a course video, description, and more. Draft the text students will read before deciding to enroll in your course.",
"is_checked": False, "is_checked": False,
"action_url": "SettingsDetails", "action_url": "SettingsDetails",
...@@ -331,8 +328,7 @@ class CourseFields(object): ...@@ -331,8 +328,7 @@ class CourseFields(object):
"is_checked": False, "is_checked": False,
"action_url": "SettingsDetails", "action_url": "SettingsDetails",
"action_text": "Edit Course Schedule & Details", "action_text": "Edit Course Schedule & Details",
"action_external": False}] "action_external": False}]}
}
]) ])
info_sidebar_name = String(scope=Scope.settings, default='Course Handouts') info_sidebar_name = String(scope=Scope.settings, default='Course Handouts')
show_timezone = Boolean(help="True if timezones should be shown on dates in the courseware", scope=Scope.settings, default=True) show_timezone = Boolean(help="True if timezones should be shown on dates in the courseware", scope=Scope.settings, default=True)
......
...@@ -3,8 +3,10 @@ Tests for the Shopping Cart Models ...@@ -3,8 +3,10 @@ Tests for the Shopping Cart Models
""" """
from factory import DjangoModelFactory from factory import DjangoModelFactory
from mock import patch
from django.test import TestCase from django.test import TestCase
from django.test.utils import override_settings from django.test.utils import override_settings
from django.db import DatabaseError
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE
...@@ -12,7 +14,7 @@ from shoppingcart.models import Order, OrderItem, CertificateItem, InvalidCartIt ...@@ -12,7 +14,7 @@ from shoppingcart.models import Order, OrderItem, CertificateItem, InvalidCartIt
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
from student.models import CourseEnrollment from student.models import CourseEnrollment
from course_modes.models import CourseMode from course_modes.models import CourseMode
from ..exceptions import PurchasedCallbackException from shoppingcart.exceptions import PurchasedCallbackException
class OrderTest(TestCase): class OrderTest(TestCase):
...@@ -74,6 +76,17 @@ class OrderTest(TestCase): ...@@ -74,6 +76,17 @@ class OrderTest(TestCase):
cart.purchase() cart.purchase()
self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course_id)) self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course_id))
def test_purchase_item_failure(self):
# once again, we're testing against the specific implementation of
# CertificateItem
cart = Order.get_cart_for_user(user=self.user)
CertificateItem.add_to_order(cart, self.course_id, self.cost, 'verified')
with patch('shoppingcart.models.CertificateItem.save', side_effect=DatabaseError):
with self.assertRaises(DatabaseError):
cart.purchase()
# verify that we rolled back the entire transaction
self.assertFalse(CourseEnrollment.is_enrolled(self.user, self.course_id))
class OrderItemTest(TestCase): class OrderItemTest(TestCase):
def setUp(self): def setUp(self):
......
...@@ -22,6 +22,7 @@ from mitxmako.shortcuts import render_to_response ...@@ -22,6 +22,7 @@ from mitxmako.shortcuts import render_to_response
from shoppingcart.processors import render_purchase_form_html, process_postpay_callback from shoppingcart.processors import render_purchase_form_html, process_postpay_callback
from mock import patch, Mock from mock import patch, Mock
def mock_render_purchase_form_html(*args, **kwargs): def mock_render_purchase_form_html(*args, **kwargs):
return render_purchase_form_html(*args, **kwargs) return render_purchase_form_html(*args, **kwargs)
...@@ -34,6 +35,7 @@ render_mock = Mock(side_effect=mock_render_to_response) ...@@ -34,6 +35,7 @@ render_mock = Mock(side_effect=mock_render_to_response)
postpay_mock = Mock() postpay_mock = Mock()
@override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) @override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE)
class ShoppingCartViewsTests(ModuleStoreTestCase): class ShoppingCartViewsTests(ModuleStoreTestCase):
def setUp(self): def setUp(self):
...@@ -53,7 +55,6 @@ class ShoppingCartViewsTests(ModuleStoreTestCase): ...@@ -53,7 +55,6 @@ class ShoppingCartViewsTests(ModuleStoreTestCase):
def login_user(self): def login_user(self):
self.client.login(username=self.user.username, password="password") self.client.login(username=self.user.username, password="password")
def test_add_course_to_cart_anon(self): def test_add_course_to_cart_anon(self):
resp = self.client.post(reverse('shoppingcart.views.add_course_to_cart', args=[self.course_id])) resp = self.client.post(reverse('shoppingcart.views.add_course_to_cart', args=[self.course_id]))
self.assertEqual(resp.status_code, 403) self.assertEqual(resp.status_code, 403)
...@@ -158,7 +159,7 @@ class ShoppingCartViewsTests(ModuleStoreTestCase): ...@@ -158,7 +159,7 @@ class ShoppingCartViewsTests(ModuleStoreTestCase):
@patch('shoppingcart.views.process_postpay_callback', postpay_mock) @patch('shoppingcart.views.process_postpay_callback', postpay_mock)
@patch('shoppingcart.views.render_to_response', render_mock) @patch('shoppingcart.views.render_to_response', render_mock)
def test_postpay_callback_failure(self): def test_postpay_callback_failure(self):
postpay_mock.return_value = {'success': False, 'order': self.cart, 'error_html':'ERROR_TEST!!!'} postpay_mock.return_value = {'success': False, 'order': self.cart, 'error_html': 'ERROR_TEST!!!'}
self.login_user() self.login_user()
resp = self.client.post(reverse('shoppingcart.views.postpay_callback', args=[])) resp = self.client.post(reverse('shoppingcart.views.postpay_callback', args=[]))
self.assertEqual(resp.status_code, 200) self.assertEqual(resp.status_code, 200)
......
...@@ -26,7 +26,7 @@ def add_course_to_cart(request, course_id): ...@@ -26,7 +26,7 @@ def add_course_to_cart(request, course_id):
PaidCourseRegistration.add_to_order(cart, course_id) PaidCourseRegistration.add_to_order(cart, course_id)
except ItemNotFoundError: except ItemNotFoundError:
return HttpResponseNotFound(_('The course you requested does not exist.')) return HttpResponseNotFound(_('The course you requested does not exist.'))
if request.method == 'GET': ### This is temporary for testing purposes and will go away before we pull if request.method == 'GET': # This is temporary for testing purposes and will go away before we pull
return HttpResponseRedirect(reverse('shoppingcart.views.show_cart')) return HttpResponseRedirect(reverse('shoppingcart.views.show_cart'))
return HttpResponse(_("Course added to cart.")) return HttpResponse(_("Course added to cart."))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment