def test_order_found(self): """ If the order is located, the view should pass the data from the API. """ with mock_order_endpoint(order_number=self.ORDER_NUMBER, response=self.MOCK_ORDER): response = self.client.get(self.path) self.assertEqual(response.status_code, 200) actual = json.loads(response.content) self.assertEqual(actual, self.MOCK_ORDER)
def test_refund_cutoff_date_with_api_error(self, exception): """ Verify that dashboard will not throw internal server error if HttpClientError raised while getting order detail for ecommerce. """ # importing this after overriding value of ECOMMERCE_API_URL from commerce.tests.mocks import mock_order_endpoint self.client.login(username=self.user.username, password=self.USER_PASSWORD) with mock_order_endpoint(order_number=self.ORDER_NUMBER, exception=exception, reset_on_exit=False): response = self.client.post(reverse('student.views.dashboard', args=[])) self.assertEqual(response.status_code, 200)
def test_order_not_found(self): """ If the order is not found, the view should return a 404. """ with mock_order_endpoint(order_number=self.ORDER_NUMBER, exception=exceptions.HttpNotFoundError): response = self.client.get(self.path) self.assertEqual(response.status_code, 404)