'Check that when working with a product being processed by the
ecommerce api, we correctly call to that api to create a basket.'

@httpretty.activate
@override_settings(ECOMMERCE_API_URL=TEST_API_URL)
def test_create_basket(self):

    user = UserFactory.create(username='test-username')
    course_mode = CourseModeFactory.create(sku='test-sku').to_tuple()
    expected_payment_data = {'foo': 'bar'}
    httpretty.register_uri(httpretty.POST, '{}/baskets/'.format(TEST_API_URL), body=json.dumps({'payment_data': expected_payment_data}), content_type='application/json')
    with mock.patch('lms.djangoapps.verify_student.views.audit_log') as mock_audit_log:
        actual_payment_data = checkout_with_ecommerce_service(user, 'dummy-course-key', course_mode, 'test-processor')
        self.assertTrue(mock_audit_log.called)
    self.assertEqual(json.loads(httpretty.last_request().body), {'products': [{'sku': 'test-sku'}], 'checkout': True, 'payment_processor_name': 'test-processor'})
    self.assertEqual(actual_payment_data, expected_payment_data)
