Exemple #1
0
    def test_get_returns_error(self):
        with self.subTest("Routing lookup error"):
            self.routing.get_end_point.side_effect = Exception

            response = self.fetch(test_request_handler.build_url(),
                                  method="GET")

            self.assertEqual(response.code, 500)

        with self.subTest("Reliability lookup error"):
            self.routing.get_reliability.side_effect = Exception

            response = self.fetch(test_request_handler.build_url(),
                                  method="GET")

            self.assertEqual(response.code, 500)
Exemple #2
0
    def test_get(self):
        self.routing.get_end_point.return_value = test_utilities.awaitable(
            END_POINT_DETAILS)

        response = self.fetch(test_request_handler.build_url(), method="GET")

        self.assertEqual(response.code, 200)
        self.assertEqual(END_POINT_DETAILS, json.loads(response.body))
        self.routing.get_end_point.assert_called_with(
            test_request_handler.ORG_CODE, test_request_handler.SERVICE_ID)
Exemple #3
0
    def test_get_handles_missing_params(self):
        with self.subTest("Missing Org Code"):
            response = self.fetch(test_request_handler.build_url(
                org_code=None, service_id=test_request_handler.SERVICE_ID),
                                  method="GET")

            self.assertEqual(response.code, 400)

        with self.subTest("Missing Service ID"):
            response = self.fetch(test_request_handler.build_url(
                org_code=test_request_handler.ORG_CODE, service_id=None),
                                  method="GET")

            self.assertEqual(response.code, 400)

        with self.subTest("Missing Org Code & Service ID"):
            response = self.fetch(test_request_handler.build_url(
                org_code=None, service_id=None),
                                  method="GET")

            self.assertEqual(response.code, 400)
Exemple #4
0
    def test_get_returns_error(self):
        self.routing.get_end_point.side_effect = Exception

        response = self.fetch(test_request_handler.build_url(), method="GET")

        self.assertEqual(response.code, 500)