Skip to content

Commit 12aade6

Browse files
committed
Pulls HTTP methods to class attr
1 parent 6f2c217 commit 12aade6

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
@@ -84,7 +84,7 @@ def test__init__(self):
8484
self.assertEqual(default_client.host, self.host)
8585
self.assertEqual(default_client.request_headers, {})
8686
self.assertIs(default_client.timeout, None)
87-
methods = ['delete', 'get', 'patch', 'post', 'put']
87+
methods = set(('delete', 'get', 'patch', 'post', 'put'))
8888
self.assertEqual(default_client.methods, methods)
8989
self.assertEqual(default_client._version, None)
9090
self.assertEqual(default_client._url_path, [])
@@ -97,7 +97,7 @@ def test__init__(self):
9797
timeout=10)
9898
self.assertEqual(client.host, self.host)
9999
self.assertEqual(client.request_headers, request_headers)
100-
methods = ['delete', 'get', 'patch', 'post', 'put']
100+
methods = set(('delete', 'get', 'patch', 'post', 'put'))
101101
self.assertEqual(client.methods, methods)
102102
self.assertEqual(client._version, 3)
103103
self.assertEqual(client._url_path, [])
@@ -151,7 +151,7 @@ def test__getattr__(self):
151151
self.assertEqual(client._version, 3)
152152

153153
# Test GET
154-
mock_client._url_path + ['test']
154+
mock_client._url_path += ['test']
155155
r = mock_client.get()
156156
self.assertEqual(r.status_code, 200)
157157

0 commit comments

Comments
 (0)