Skip to content
Snippets Groups Projects
Commit 9cd691dc authored by Robert Habermann's avatar Robert Habermann
Browse files

rename result.content to _content and response_type to _content

parent 1109b2d8
No related branches found
No related tags found
No related merge requests found
......@@ -682,7 +682,7 @@ class Client(object):
self.result_list_ticket_search = []
self.result_json = None
self.result_content = None
self._result_content = None
self.result_status_code = None
"""
......@@ -1272,21 +1272,21 @@ class Client(object):
# get and set new data
self.result_json = response.json()
self.result_status_code = response.status_code
# TODO 2016-04-24 (RH) can this deep copy go?
self._result_json_original = copy.deepcopy(self.result_json)
self.result_status_code = response.status_code
self.result_content = response.content
self._result_content = response.content
if self.operation == "SessionCreate":
self.response_type = "SessionID"
self._result_type = "SessionID"
elif self.operation == "TicketGet":
self.response_type = "Ticket"
self._result_type = "Ticket"
elif self.operation == "TicketCreate":
self.response_type = "TicketID"
self._result_type = "TicketID"
elif self.operation == "TicketSearch":
self.response_type = "TicketID"
self._result_type = "TicketID"
elif self.operation == "TicketUpdate":
self.response_type = "TicketID"
self._result_type = "TicketID"
else:
raise NotImplementedError("Unknown Operation!")
......@@ -1294,12 +1294,12 @@ class Client(object):
if self.operation == "TicketSearch":
if not self.result_json:
return True
if self.result_json.get(self.response_type, None):
if self.result_json.get(self._result_type, None):
self.result_list_ticket_search = self.result_json['TicketID']
return True
# now handle other operations
if self.result_json.get(self.response_type, None):
if self.result_json.get(self._result_type, None):
self.result_error = False
elif self.result_json.get("Error", None):
self.result_error = True
......
......@@ -743,7 +743,7 @@ class ClientTests(unittest.TestCase):
client._parse_and_validate_response(mocked_response)
self.assertEqual(client.response_type, 'SessionID')
self.assertEqual(client._result_type, 'SessionID')
def test__validate_response_operation_ticket_get(self):
"""Test _validate_response with TicketGet"""
......@@ -765,7 +765,7 @@ class ClientTests(unittest.TestCase):
client._parse_and_validate_response(mocked_response)
self.assertEqual(client.response_type, 'Ticket')
self.assertEqual(client._result_type, 'Ticket')
self.assertDictEqual(client.result_json, tkt)
def test__validate_response_operation_ticket_create(self):
......@@ -781,7 +781,7 @@ class ClientTests(unittest.TestCase):
client._parse_and_validate_response(mocked_response)
self.assertEqual(client.response_type, 'TicketID')
self.assertEqual(client._result_type, 'TicketID')
self.assertDictEqual(client.result_json, {u'ArticleID': u'26',
u'TicketID': u'9',
u'TicketNumber': u'000008'})
......@@ -796,7 +796,7 @@ class ClientTests(unittest.TestCase):
mocked_response.json.return_value = {u'TicketID': u'9', u'TicketNumber': u'000008'}
client._parse_and_validate_response(mocked_response)
self.assertEqual(client.response_type, 'TicketID')
self.assertEqual(client._result_type, 'TicketID')
self.assertDictEqual(client.result_json, {u'TicketID': u'9',
u'TicketNumber': u'000008'})
......@@ -810,7 +810,7 @@ class ClientTests(unittest.TestCase):
mocked_response.json.return_value = {u'TicketID': [u'9']}
client._parse_and_validate_response(mocked_response)
self.assertEqual(client.response_type, 'TicketID')
self.assertEqual(client._result_type, 'TicketID')
self.assertDictEqual(client.result_json, {u'TicketID': [u'9']})
def test__validate_response_operation_ticket_search_empty(self):
......@@ -823,7 +823,7 @@ class ClientTests(unittest.TestCase):
mocked_response.json.return_value = {}
client._parse_and_validate_response(mocked_response)
self.assertEqual(client.response_type, 'TicketID')
self.assertEqual(client._result_type, 'TicketID')
self.assertDictEqual(client.result_json, {})
def test__validate_response_operation_ticket_search_nonsense(self):
......@@ -838,7 +838,7 @@ class ClientTests(unittest.TestCase):
self.assertRaises(ResponseJSONParseError,
client._parse_and_validate_response,
mocked_response)
self.assertEqual(client.response_type, 'TicketID')
self.assertEqual(client._result_type, 'TicketID')
self.assertTrue(client.result_error)
self.assertDictEqual(client.result_json, {u'FooBar': [u'1', u'3']})
......
......@@ -25,7 +25,7 @@ class PyOTRSResponsesTests(unittest.TestCase):
self.assertIsNone(obj.result_json)
self.assertIsNone(obj.result_status_code)
self.assertIsNone(obj.result_content)
self.assertIsNone(obj._result_content)
self.assertIsNone(obj.session_id_store.value)
with responses.RequestsMock(assert_all_requests_are_fired=True) as rsps:
......@@ -53,7 +53,7 @@ class PyOTRSResponsesTests(unittest.TestCase):
self.assertIsNone(obj.result_json)
self.assertIsNone(obj.result_status_code)
self.assertIsNone(obj.result_content)
self.assertIsNone(obj._result_content)
self.assertIsNone(obj.session_id_store.value)
with responses.RequestsMock(assert_all_requests_are_fired=True) as rsps:
......@@ -85,7 +85,7 @@ class PyOTRSResponsesTests(unittest.TestCase):
self.assertIsNone(obj.result_json)
self.assertIsNone(obj.result_status_code)
self.assertIsNone(obj.result_content)
self.assertIsNone(obj._result_content)
self.assertIsNone(obj.session_id_store.value)
mock_validate_resp.return_value = False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment