Skip to content

Commit 4ddc084

Browse files
committed
move the list to the Reqeust class
1 parent 8e31451 commit 4ddc084

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

amadeus/client/request.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ def __build_user_agent(self):
8484
user_agent += ' {0}/{1}'.format(self.app_id, self.app_version)
8585
return user_agent
8686

87+
# The list of paths that require HTTP override in header
88+
list_httpoverride = [
89+
'/v2/shopping/flight-offers',
90+
'/v1/shopping/seatmaps',
91+
'/v1/shopping/availability/flight-availabilities',
92+
'/v2/shopping/flight-offers/prediction',
93+
'/v1/shopping/flight-offers/pricing?',
94+
'/v1/shopping/flight-offers/upselling'
95+
]
96+
8797
# Builds a HTTP Request object based on the path, params, and verb
8898
def __build_http_request(self):
8999
# Requests token in case has not been set
@@ -95,18 +105,9 @@ def __build_http_request(self):
95105
# Adds the authentication header since the bearer token has been set
96106
self.headers['Authorization'] = self.bearer_token
97107

98-
# List of paths that require HTTP override in header
99-
list_httpoverride = [
100-
'/v2/shopping/flight-offers',
101-
'/v1/shopping/seatmaps',
102-
'/v1/shopping/availability/flight-availabilities',
103-
'/v2/shopping/flight-offers/prediction',
104-
'/v1/shopping/flight-offers/pricing?',
105-
'/v1/shopping/flight-offers/upselling'
106-
]
107-
108108
if self.verb == 'POST':
109-
if self.path in list_httpoverride:
109+
#Adds HTTP override in Header for the list of paths required
110+
if self.path in Request.list_httpoverride:
110111
self.headers['X-HTTP-Method-Override'] = 'GET'
111112
if type(self.params) is dict:
112113
return HTTPRequest(self.url, headers=self.headers, method='POST',

specs/client/request_spec.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,12 @@
8686
expect(self.request.http_request.data).to(
8787
equal(b'{\"foo\": \"bar\"}'))
8888

89-
with it('should return X-HTTP-Method-Override in header'):
90-
self.path =[
91-
'/v2/shopping/flight-offers',
92-
'/v1/shopping/seatmaps',
93-
'/v1/shopping/availability/flight-availabilities',
94-
'/v2/shopping/flight-offers/prediction',
95-
'/v1/shopping/flight-offers/pricing?',
96-
'/v1/shopping/flight-offers/upselling'
97-
]
98-
for i in self.path:
89+
with it('should return X-HTTP-Method-Override in header for some POST requests'):
90+
for path in Request.list_httpoverride:
9991
self.request = Request({
10092
'host': self.host,
10193
'verb': 'POST',
102-
'path': self.path,
94+
'path': path,
10395
'params': self.params,
10496
'bearer_token': self.bearer_token,
10597
'client_version': self.client_version,
@@ -109,10 +101,10 @@
109101
'port': self.port,
110102
'ssl': self.ssl
111103
})
112-
104+
113105
expect(self.request.http_request).to(be_a(HTTPRequest))
114-
expect(self.request.http_request.get_header('X-HTTP-Method-Override')).to(
115-
equal('GET')
106+
expect(self.request.headers['X-HTTP-Method-Override']
107+
).to(equal('GET')
116108
)
117109

118110
with it('should handle a custom scheme and port'):

0 commit comments

Comments
 (0)