def test_add_to_order(self): reg1 = PaidCourseRegistration.add_to_order(self.cart, self.course_id) self.assertEqual(reg1.unit_cost, self.cost) self.assertEqual(reg1.line_cost, self.cost) self.assertEqual(reg1.unit_cost, self.course_mode.min_price) self.assertEqual(reg1.mode, "honor") self.assertEqual(reg1.user, self.user) self.assertEqual(reg1.status, "cart") self.assertTrue(PaidCourseRegistration.part_of_order(self.cart, self.course_id)) self.assertFalse(PaidCourseRegistration.part_of_order(self.cart, self.course_id + "abcd")) self.assertEqual(self.cart.total_cost, self.cost)
def test_add_to_order(self): reg1 = PaidCourseRegistration.add_to_order(self.cart, self.course_id) self.assertEqual(reg1.unit_cost, self.cost) self.assertEqual(reg1.line_cost, self.cost) self.assertEqual(reg1.unit_cost, self.course_mode.min_price) self.assertEqual(reg1.mode, "honor") self.assertEqual(reg1.user, self.user) self.assertEqual(reg1.status, "cart") self.assertTrue( PaidCourseRegistration.part_of_order(self.cart, self.course_id)) self.assertFalse( PaidCourseRegistration.part_of_order(self.cart, self.course_id + "abcd")) self.assertEqual(self.cart.total_cost, self.cost)
def test_add_course_to_cart_success(self): self.login_user() resp = self.client.post( reverse('shoppingcart.views.add_course_to_cart', args=[self.course_id])) self.assertEqual(resp.status_code, 200) self.assertTrue( PaidCourseRegistration.part_of_order(self.cart, self.course_id))
def test_add_with_default_mode(self): """ Tests add_to_cart where the mode specified in the argument is NOT in the database and NOT the default "honor". In this case it just adds the user in the CourseMode.DEFAULT_MODE, 0 price """ reg1 = PaidCourseRegistration.add_to_order(self.cart, self.course_id, mode_slug="DNE") self.assertEqual(reg1.unit_cost, 0) self.assertEqual(reg1.line_cost, 0) self.assertEqual(reg1.mode, "honor") self.assertEqual(reg1.user, self.user) self.assertEqual(reg1.status, "cart") self.assertEqual(self.cart.total_cost, 0) self.assertTrue(PaidCourseRegistration.part_of_order(self.cart, self.course_id))
def test_add_with_default_mode(self): """ Tests add_to_cart where the mode specified in the argument is NOT in the database and NOT the default "honor". In this case it just adds the user in the CourseMode.DEFAULT_MODE, 0 price """ reg1 = PaidCourseRegistration.add_to_order(self.cart, self.course_id, mode_slug="DNE") self.assertEqual(reg1.unit_cost, 0) self.assertEqual(reg1.line_cost, 0) self.assertEqual(reg1.mode, "honor") self.assertEqual(reg1.user, self.user) self.assertEqual(reg1.status, "cart") self.assertEqual(self.cart.total_cost, 0) self.assertTrue( PaidCourseRegistration.part_of_order(self.cart, self.course_id))
def test_add_course_to_cart_success(self): self.login_user() resp = self.client.post(reverse('shoppingcart.views.add_course_to_cart', args=[self.course_id])) self.assertEqual(resp.status_code, 200) self.assertTrue(PaidCourseRegistration.part_of_order(self.cart, self.course_id))