'DRY helper.
Ensures that checkout functions were invoked as
expected during execution of the create_order endpoint.'

def _assert_checked_out(self, post_params, patched_create_order, expected_course_key, expected_mode_slug, expected_status_code=200):

    post_params.setdefault('processor', None)
    response = self.client.post(reverse('verify_student_create_order'), post_params)
    self.assertEqual(response.status_code, expected_status_code)
    if (expected_status_code == 200):
        self.assertTrue(patched_create_order.called)
        args = self._get_checkout_args(patched_create_order)
        self.assertEqual(args['user'], self.user)
        self.assertEqual(args['course_key'], expected_course_key)
        self.assertEqual(args['course_mode'].slug, expected_mode_slug)
        data = json.loads(response.content)
        self.assertEqual(set(data.keys()), PAYMENT_DATA_KEYS)
    else:
        self.assertFalse(patched_create_order.called)
