Skip to content

Commit bdb061c

Browse files
committed
Pulls HTTP methods to class attr
1 parent 749f22c commit bdb061c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

python_http_client/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ def to_dict(self):
6363
class Client(object):
6464
"""Quickly and easily access any REST or REST-like API."""
6565

66+
# These are the supported HTTP verbs
67+
methods = {'delete', 'get', 'patch', 'post', 'put'}
68+
6669
def __init__(self,
6770
host,
6871
request_headers=None,
@@ -89,8 +92,6 @@ def __init__(self,
8992
self._version = version
9093
# _url_path keeps track of the dynamically built url
9194
self._url_path = url_path or []
92-
# These are the supported HTTP verbs
93-
self.methods = ['delete', 'get', 'patch', 'post', 'put']
9495
# APPEND SLASH set
9596
self.append_slash = append_slash
9697
self.timeout = timeout

tests/test_unit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test__init__(self):
8080
self.assertEqual(default_client.host, self.host)
8181
self.assertEqual(default_client.request_headers, {})
8282
self.assertIs(default_client.timeout, None)
83-
methods = ['delete', 'get', 'patch', 'post', 'put']
83+
methods = {'delete', 'get', 'patch', 'post', 'put'}
8484
self.assertEqual(default_client.methods, methods)
8585
self.assertIsNone(default_client._version)
8686
self.assertEqual(default_client._url_path, [])
@@ -93,7 +93,7 @@ def test__init__(self):
9393
timeout=10)
9494
self.assertEqual(client.host, self.host)
9595
self.assertEqual(client.request_headers, request_headers)
96-
methods = ['delete', 'get', 'patch', 'post', 'put']
96+
methods = {'delete', 'get', 'patch', 'post', 'put'}
9797
self.assertEqual(client.methods, methods)
9898
self.assertEqual(client._version, 3)
9999
self.assertEqual(client._url_path, [])
@@ -160,7 +160,7 @@ def test__getattr__(self):
160160
self.assertEqual(client._version, 3)
161161

162162
# Test GET
163-
mock_client._url_path + ['test']
163+
mock_client._url_path += ['test']
164164
r = mock_client.get()
165165
self.assertEqual(r.status_code, 200)
166166

0 commit comments

Comments
 (0)