Beispiel #1
0
    def test_make_request_get(self, mock_requests):
        expected_headers = {
            "User-Agent": "SouthwestAndroid/7.2.1 android/10",
            "Accept": "application/json",
            "X-API-Key": swa.API_KEY,
            "X-Channel-ID": "MWEB"
        }
        expected_url = "https://mobile.southwest.com/api/foo/123456/bar"
        fake_data = ''

        _ = swa._make_request(  # NOQA
            "get", "foo/123456/bar", fake_data)

        mock_requests.get.assert_called_with(expected_url,
                                             params=fake_data,
                                             headers=expected_headers)
    def test_make_request_post(self, mock_requests):
        expected_headers = {
            "User-Agent": "Southwest/4.9.1 CFNetwork/887 Darwin/17.0.0",
            "Content-Type":
            "application/vnd.swacorp.com.mobile.boarding-passes-v1.0+json",
            "X-Api-Key": swa.API_KEY,
            "Accept-Language": "en-US;q=1"
        }
        expected_url = "https://mobile.southwest.com/api/extensions/v1/mobile/foo/123456/bar"
        fake_data = {}

        _ = swa._make_request(  # NOQA
            "/foo/123456/bar",
            fake_data,
            content_type=
            "application/vnd.swacorp.com.mobile.boarding-passes-v1.0+json")

        mock_requests.post.assert_called_with(expected_url,
                                              json=fake_data,
                                              headers=expected_headers,
                                              verify=False)
Beispiel #3
0
 def test_make_request_invalid_method(self, mock_requests):
     with self.assertRaises(NotImplementedError):
         swa._make_request("foo", "/foo/123456/bar", {}, "application/json")
 def test_make_request_invalid_method(self, mock_requests):
     with self.assertRaises(AssertionError):
         swa._make_request("/foo/123456/bar", {},
                           "application/json",
                           method="foo")