Skip to content

Commit 239201d

Browse files
committed
Single quote to be standard.
pep8
1 parent 98a338e commit 239201d

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

tests/ubersmith_request_get_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import unittest
15+
1516
from hamcrest import assert_that, equal_to
1617
from mock import patch, MagicMock
17-
1818
import ubersmith_client
1919
from tests.ubersmith_json.response_data_structure import a_response_data
2020

@@ -65,7 +65,7 @@ def test_api_get_method_returns_with_arguments(self, request_mock):
6565
expected_call()
6666

6767
def expect_a_ubersmith_call(self, requests_mock, returning=None, **kwargs):
68-
response = MagicMock(status_code=200, headers={"content-type": "application/json"})
68+
response = MagicMock(status_code=200, headers={'content-type': 'application/json'})
6969
requests_mock.get = MagicMock(return_value=response)
7070
response.json = MagicMock(return_value=returning)
7171

tests/ubersmith_request_post_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import unittest
15+
1516
from hamcrest import assert_that, equal_to, calling, raises
1617
from mock import patch, MagicMock
17-
1818
import ubersmith_client
1919
from tests.ubersmith_json.response_data_structure import a_response_data
2020

@@ -69,14 +69,14 @@ def test_api_raises_exception_with_if_data_status_is_false(self, requests_mock):
6969
data = a_response_data(status=False,
7070
error_code=1,
7171
error_message='invalid method specified: client.miss',
72-
data="schwifty")
72+
data='schwifty')
7373
ubersmith_api = ubersmith_client.api.init(self.url, self.username, self.password)
7474

7575
self.expect_a_ubersmith_call_post(requests_mock, method='client.miss', returning=data)
7676
assert_that(calling(ubersmith_api.client.miss), raises(ubersmith_client.exceptions.UbersmithException))
7777

7878
def expect_a_ubersmith_call_post(self, requests_mock, returning=None, status_code=200, **kwargs):
79-
response = MagicMock(status_code=status_code, headers={"content-type": "application/json"})
79+
response = MagicMock(status_code=status_code, headers={'content-type': 'application/json'})
8080
requests_mock.post = MagicMock(return_value=response)
8181
response.json = MagicMock(return_value=returning)
8282

tests/ubersmith_request_test.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515

1616
import ubersmith_client
1717
from mock import Mock, patch
18-
1918
from hamcrest import assert_that, raises, calling, equal_to
2019
from requests.exceptions import ConnectionError, Timeout
21-
2220
from ubersmith_client.exceptions import UbersmithException, BadRequest, UnknownError, Forbidden, NotFound, Unauthorized, \
2321
UbersmithConnectionError, \
2422
UbersmithTimeout
@@ -33,7 +31,7 @@ def setUp(self):
3331
self.password = 'test'
3432

3533
def test_process_ubersmith_response(self):
36-
response = Mock(status_code=200, headers={"content-type": "application/json"})
34+
response = Mock(status_code=200, headers={'content-type': 'application/json'})
3735

3836
json_data = {
3937
'client_id': '1',
@@ -47,11 +45,11 @@ def test_process_ubersmith_response(self):
4745
self.assertDictEqual(json_data, UbersmithRequest.process_ubersmith_response(response))
4846

4947
def test_process_ubersmith_response_not_application_json(self):
50-
response = Mock(status_code=200, headers={"content-type": "text/html"}, content="42")
48+
response = Mock(status_code=200, headers={'content-type': 'text/html'}, content='42')
5149
assert_that(response.content, equal_to(UbersmithRequest.process_ubersmith_response(response)))
5250

5351
def test_process_ubersmith_response_raise_exception(self):
54-
response = Mock(status_code=400, headers={"content-type": "application/json"})
52+
response = Mock(status_code=400, headers={'content-type': 'application/json'})
5553
assert_that(calling(UbersmithRequest.process_ubersmith_response).with_args(response), raises(BadRequest))
5654

5755
response.status_code = 401
@@ -69,7 +67,7 @@ def test_process_ubersmith_response_raise_exception(self):
6967
response.status_code = 200
7068
response.json = Mock(return_value={'status': False, 'error_code': 42, 'error_message': 'come and watch tv'})
7169
assert_that(calling(UbersmithRequest.process_ubersmith_response).with_args(response),
72-
raises(UbersmithException, "Error code 42 - message: come and watch tv"))
70+
raises(UbersmithException, 'Error code 42 - message: come and watch tv'))
7371

7472
@patch('ubersmith_client.ubersmith_request_post.requests')
7573
def test_api_method_returns_handle_connection_error_exception(self, requests_mock):

ubersmith_client/exceptions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ def __init__(self, code):
6464

6565
class UbersmithConnectionError(UbersmithException):
6666
def __init__(self, url):
67-
super(UbersmithConnectionError, self).__init__(message="Could not connect to {0}".format(url))
67+
super(UbersmithConnectionError, self).__init__(message='Could not connect to {0}'.format(url))
6868

6969

7070
class UbersmithTimeout(UbersmithException):
7171
def __init__(self, url, timeout):
72-
super(UbersmithTimeout, self)\
73-
.__init__(message='Trying to connect to {url} timed out after {timeout} seconds'.format(url=url, timeout=timeout))
72+
super(UbersmithTimeout, self) \
73+
.__init__(
74+
message='Trying to connect to {url} timed out after {timeout} seconds'.format(url=url, timeout=timeout))

ubersmith_client/ubersmith_request.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def _process_request(self, method, **kwargs):
4444
raise UbersmithTimeout(self.url, self.timeout)
4545

4646
def _build_request_params(self, kwargs):
47-
_methods = ".".join(self.methods)
48-
kwargs['method'] = "{0}.{1}".format(self.module, _methods)
47+
_methods = '.'.join(self.methods)
48+
kwargs['method'] = '{0}.{1}'.format(self.module, _methods)
4949

5050
@staticmethod
5151
def process_ubersmith_response(response):
@@ -60,6 +60,6 @@ def process_ubersmith_response(response):
6060
response_json['error_message']
6161
)
6262

63-
return response.json()["data"]
63+
return response.json()['data']
6464

6565
return response.content

0 commit comments

Comments
 (0)