Skip to content

Commit 4a2a272

Browse files
committed
Pulls HTTP methods to class attr
1 parent fa72b74 commit 4a2a272

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

python_http_client/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""HTTP Client library"""
22
import json
3+
34
from .exceptions import handle_error
45

56
try:
@@ -62,6 +63,9 @@ def to_dict(self):
6263
class Client(object):
6364
"""Quickly and easily access any REST or REST-like API."""
6465

66+
# These are the supported HTTP verbs
67+
methods = set(('delete', 'get', 'patch', 'post', 'put'))
68+
6569
def __init__(self,
6670
host,
6771
request_headers=None,
@@ -88,8 +92,6 @@ def __init__(self,
8892
self._version = version
8993
# _url_path keeps track of the dynamically built url
9094
self._url_path = url_path or []
91-
# These are the supported HTTP verbs
92-
self.methods = ['delete', 'get', 'patch', 'post', 'put']
9395
# APPEND SLASH set
9496
self.append_slash = append_slash
9597
self.timeout = timeout

tests/test_unit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test__init__(self):
8181
self.assertEqual(default_client.host, self.host)
8282
self.assertEqual(default_client.request_headers, {})
8383
self.assertIs(default_client.timeout, None)
84-
methods = ['delete', 'get', 'patch', 'post', 'put']
84+
methods = set(('delete', 'get', 'patch', 'post', 'put'))
8585
self.assertEqual(default_client.methods, methods)
8686
self.assertIsNone(default_client._version)
8787
self.assertEqual(default_client._url_path, [])
@@ -94,7 +94,7 @@ def test__init__(self):
9494
timeout=10)
9595
self.assertEqual(client.host, self.host)
9696
self.assertEqual(client.request_headers, request_headers)
97-
methods = ['delete', 'get', 'patch', 'post', 'put']
97+
methods = set(('delete', 'get', 'patch', 'post', 'put'))
9898
self.assertEqual(client.methods, methods)
9999
self.assertEqual(client._version, 3)
100100
self.assertEqual(client._url_path, [])
@@ -148,7 +148,7 @@ def test__getattr__(self):
148148
self.assertEqual(client._version, 3)
149149

150150
# Test GET
151-
mock_client._url_path + ['test']
151+
mock_client._url_path += ['test']
152152
r = mock_client.get()
153153
self.assertEqual(r.status_code, 200)
154154

0 commit comments

Comments
 (0)