Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
[pep8]: reformatted some dicts the tests/test.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tasdikrahman committed Apr 5, 2017
1 parent ef8150a commit 13848ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
29 changes: 15 additions & 14 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
except Exception as e:
import mock


class TestModule(unittest.TestCase):
"""Checks for the sanity of all module methods"""

Expand Down Expand Up @@ -56,8 +57,8 @@ def test_meaning_not_found(self, mock_api_call):
@mock.patch('vocabulary.vocabulary.requests.get')
def test_meaning_key_error(self, mock_api_call):
res = {
"result" : "ok",
"phrase" : "humming"
"result": "ok",
"phrase": "humming"
}

mock_api_call.return_value = mock.Mock()
Expand Down Expand Up @@ -111,8 +112,8 @@ def test_synonynm_not_found(self, mock_api_call):
@mock.patch('vocabulary.vocabulary.requests.get')
def test_synonynm_tuc_key_error(self, mock_api_call):
res = {
"result" : "ok",
"phrase" : "angry"
"result": "ok",
"phrase": "angry"
}

mock_api_call.return_value = mock.Mock()
Expand All @@ -124,9 +125,9 @@ def test_synonynm_tuc_key_error(self, mock_api_call):
@mock.patch('vocabulary.vocabulary.requests.get')
def test_synonynm_empty_list(self, mock_api_call):
res = {
"result" : "ok",
"tuc" : [],
"phrase" : "angry"
"result": "ok",
"tuc": [],
"phrase": "angry"
}

mock_api_call.return_value = mock.Mock()
Expand Down Expand Up @@ -177,8 +178,8 @@ def test_translate_not_found(self, mock_api_call):
@mock.patch('vocabulary.vocabulary.requests.get')
def test_translate_tuc_key_error(self, mock_api_call):
res = {
"result" : "ok",
"phrase" : "english"
"result": "ok",
"phrase": "english"
}

mock_api_call.return_value = mock.Mock()
Expand All @@ -190,9 +191,9 @@ def test_translate_tuc_key_error(self, mock_api_call):
@mock.patch('vocabulary.vocabulary.requests.get')
def test_translate_empty_list(self, mock_api_call):
res = {
"result" : "ok",
"tuc" : [],
"phrase" : "english"
"result": "ok",
"tuc": [],
"phrase": "english"
}

mock_api_call.return_value = mock.Mock()
Expand Down Expand Up @@ -306,7 +307,6 @@ def test_usageExample_not_found(self, mock_api_call):

self.assertFalse(vb.usage_example("hillock"))


@mock.patch('vocabulary.vocabulary.requests.get')
def test_usageExample_empty_list(self, mock_api_call):
res = {
Expand Down Expand Up @@ -414,7 +414,7 @@ def test_respond_as_dict_2(self):

def test_respond_as_dict_3(self):
data = json.loads('{"text": ["hummus"]}')
expected_result = {"text" : "hummus"}
expected_result = {"text": "hummus"}
result = rp().respond(data, 'dict')
if sys.version_info[:2] <= (2, 7):
self.assertItemsEqual(expected_result, result)
Expand Down Expand Up @@ -448,5 +448,6 @@ def test_respond_as_list_3(self):
else:
self.assertCountEqual(expected_result, result)


if __name__ == "__main__":
unittest.main()
7 changes: 2 additions & 5 deletions vocabulary/responselib.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""


import json

__version__ = '0.0.1'
Expand All @@ -37,8 +36,6 @@ class Response(object):
| | |
"""



def __respond_with_dict(self, data):
"""
Builds a python dictionary from a json object
Expand Down Expand Up @@ -98,8 +95,8 @@ def respond(self, data, format='json'):
:returns: a python specified object
"""
dispatchers = {
"dict" : self.__respond_with_dict,
"list" : self.__respond_with_list
"dict": self.__respond_with_dict,
"list": self.__respond_with_list
}

if not dispatchers.get(format, False):
Expand Down

0 comments on commit 13848ea

Please sign in to comment.