def test_request_response_all_serialization(self):
     e = RequestResponseAll(
         requests=[
             RequestResponse(
                 request=RequestResponseRequest(method="GET", url="test"),
                 response_definition=RequestResponseDefinition(status=200)),
         ],
         meta=RequestResponseAllMeta(total=1),
         request_journal_disabled=False,
     )
     serialized = e.get_json_data()
     self.assertDictContainsKeyWithValue(serialized,
                                         "requestJournalDisabled", False)
     self.assertDictContainsKeyWithValue(serialized, "requests", [
         {
             "request": {
                 "method": "GET",
                 "url": "test"
             },
             "responseDefinition": {
                 "status": 200
             }
         },
     ])
     self.assertDictContainsKeyWithValue(serialized, "meta", {"total": 1})
 def test_request_response_all_serialization(self):
     e = RequestResponseAll(
         requests=[RequestResponse(
             request=RequestResponseRequest(method='GET', url='test'),
             response_definition=RequestResponseDefinition(status=200)
         ), ],
         meta=RequestResponseAllMeta(total=1),
         request_journal_disabled=False
     )
     serialized = e.get_json_data()
     self.assertDictContainsKeyWithValue(serialized, 'requestJournalDisabled', False)
     self.assertDictContainsKeyWithValue(serialized, 'requests', [
         {'request': {'method': 'GET', 'url': 'test'}, 'responseDefinition': {'status': 200}},
     ])
     self.assertDictContainsKeyWithValue(serialized, 'meta', {'total': 1})
 def test_request_response_all_deserialization(self):
     serialized = {
         "requests": [
             {
                 "request": {
                     "method": "GET",
                     "url": "test"
                 },
                 "responseDefinition": {
                     "status": 200
                 }
             },
         ],
         "meta": {
             "total": 1
         },
         "requestJournalDisabled":
         False,
     }
     e = RequestResponseAll.from_dict(serialized)
     self.assertIsInstance(e, RequestResponseAll)
     self.assertEquals(False, e.request_journal_disabled)
     self.assertIsInstance(e.requests, list)
     rr = e.requests[0]
     self.assertIsInstance(rr, RequestResponse)
     self.assertIsInstance(rr.request, RequestResponseRequest)
     self.assertEquals("GET", rr.request.method)
     self.assertEquals("test", rr.request.url)
     self.assertIsInstance(rr.response_definition,
                           RequestResponseDefinition)
     self.assertEquals(200, rr.response_definition.status)
     self.assertIsInstance(e.meta, RequestResponseAllMeta)
     self.assertEquals(1, e.meta.total)
示例#4
0
    def get_all_received_requests(cls, limit=None, since=None, parameters={}):
        if limit is not None and limit > 0:
            parameters['limit'] = limit
        if since is not None:
            parameters['since'] = since

        response = cls.REST_CLIENT.get(cls.endpoint(), params=parameters, headers=make_headers())
        response = cls.REST_CLIENT.handle_response(response)

        return RequestResponseAll.from_dict(response.json())
 def test_request_response_all_deserialization(self):
     serialized = {
         'requests': [
             {'request': {'method': 'GET', 'url': 'test'}, 'responseDefinition': {'status': 200}},
         ],
         'meta': {'total': 1},
         'requestJournalDisabled': False
     }
     e = RequestResponseAll.from_dict(serialized)
     self.assertIsInstance(e, RequestResponseAll)
     self.assertEquals(False, e.request_journal_disabled)
     self.assertIsInstance(e.requests, list)
     rr = e.requests[0]
     self.assertIsInstance(rr, RequestResponse)
     self.assertIsInstance(rr.request, RequestResponseRequest)
     self.assertEquals('GET', rr.request.method)
     self.assertEquals('test', rr.request.url)
     self.assertIsInstance(rr.response_definition, RequestResponseDefinition)
     self.assertEquals(200, rr.response_definition.status)
     self.assertIsInstance(e.meta, RequestResponseAllMeta)
     self.assertEquals(1, e.meta.total)