@@ -32,15 +32,19 @@ def __init__(self, **kwargs):
3232 })
3333
3434 @patch ('commerce_coordinator.apps.orders.clients.EcommerceApiClient.get_orders' )
35- def test_ecommerce_view (self , mock_response ):
36- """We can call get_user_orders__ecommerce successfully."""
35+ def test_EcommerceApiClient (self , mock_response ):
36+ """We can call the EcommerceApiClient successfully."""
3737
3838 mock_response .return_value = self .test_response
3939 params = {'username' : 'TestUser' , "page" : 1 , "page_size" : 20 }
4040 expected_result = {
'count' :
1 ,
'results' : [{
"billing_address" : {
"first_name" :
"Diane" ,
"last_name" :
"Test" ,
"line1" :
"50 turner st" ,
"line2" :
"" ,
"postcode" :
"02135" ,
"state" :
"MA" ,
"country" :
"US" ,
"city" :
"Brighton" },
"currency" :
"USD" ,
"date_placed" :
"2021-12-20T15:09:44Z" ,
"discount" :
"0" ,
"lines" : [{
"title" :
"Seat in edX Demonstration Course with verified certificate (and ID verification)" ,
"quantity" :
1 ,
"description" :
"Seat in edX Demonstration Course with verified certificate (and ID verification)" ,
"status" :
"Complete" ,
"line_price_excl_tax" :
"149.00" ,
"unit_price_excl_tax" :
"149.00" ,
"product" : {
"id" :
3 ,
"url" :
"http://localhost:18130/api/v2/products/3/" ,
"structure" :
"child" ,
"product_class" :
"Seat" ,
"title" :
"Seat in edX Demonstration Course with verified certificate (and ID verification)" ,
"price" :
"149.00" ,
"expires" :
"2022-11-08T22:54:30.777313Z" ,
"attribute_values" : [{
"name" :
"certificate_type" ,
"code" :
"certificate_type" ,
"value" :
"verified" }, {
"name" :
"course_key" ,
"code" :
"course_key" ,
"value" :
"course-v1:edX+DemoX+Demo_Course" }, {
"name" :
"id_verification_required" ,
"code" :
"id_verification_required" ,
"value" :
True }],
"is_available_to_buy" :
True ,
"stockrecords" : [{
"id" :
3 ,
"product" :
3 ,
"partner" :
1 ,
"partner_sku" :
"8CF08E5" ,
"price_currency" :
"USD" ,
"price_excl_tax" :
"149.00" }]}}],
"number" :
"EDX-100004" ,
"payment_processor" :
"cybersource-rest" ,
"status" :
"Complete" ,
"total_excl_tax" :
"149.00" ,
"user" : {
"email" :
"[email protected] " ,
"username" :
"edx" },
"vouchers" : []}]}
# pylint: disable=line-too-long # nopep8 4141
42- # Call the new function (get_user_orders__ecommerce) , mocking the call to ecommerce_api_client.get_orders
42+ # Call the new function (EcommerceApiClient().get_orders(params)) , mocking the response
4343 ecommerce_api_client = EcommerceApiClient ()
4444 ecommerce_response = ecommerce_api_client .get_orders (params )
4545
4646 self .assertEqual (expected_result , ecommerce_response .__dict__ )
47+
48+ # also add a test for the function in views.py? (test_ecommerce_view, to call get_user_orders__ecommerce)
49+ # def test_ecommerce_view(self, mock_response):
50+ # """We can call get_user_orders__ecommerce successfully."""
0 commit comments