def test_mapping_deserialization(self):
     serialized = {
         "priority": 1,
         "request": {
             "method": "GET",
             "url": "test"
         },
         "response": {
             "status": 200,
             "statusMessage": "test2"
         },
         "persistent": False,
         "postServeActions": {
             "test": "1"
         },
         "newScenarioState": "test3",
         "requiredScenarioState": "test4",
         "scenarioName": "test5",
     }
     e = Mapping.from_dict(serialized)
     self.assertIsInstance(e, Mapping)
     self.assertEqual(1, e.priority)
     self.assertIsInstance(e.request, MappingRequest)
     self.assertEqual("GET", e.request.method)
     self.assertEqual("test", e.request.url)
     self.assertIsInstance(e.response, MappingResponse)
     self.assertEqual(200, e.response.status)
     self.assertEqual("test2", e.response.status_message)
     self.assertEqual(False, e.persistent)
     self.assertEqual({"test": "1"}, e.post_serve_actions)
     self.assertEqual("test3", e.new_scenario_state)
     self.assertEqual("test4", e.required_scenario_state)
     self.assertEqual("test5", e.scenario_name)
예제 #2
0
 def test_mapping_deserialization(self):
     serialized = {
         'priority': 1,
         'request': {
             'method': 'GET',
             'url': 'test'
         },
         'response': {
             'status': 200,
             'statusMessage': 'test2'
         },
         'persistent': False,
         'postServeActions': {
             'test': '1'
         },
         'newScenarioState': 'test3',
         'requiredScenarioState': 'test4',
         'scenarioName': 'test5'
     }
     e = Mapping.from_dict(serialized)
     self.assertIsInstance(e, Mapping)
     self.assertEquals(1, e.priority)
     self.assertIsInstance(e.request, MappingRequest)
     self.assertEquals('GET', e.request.method)
     self.assertEquals('test', e.request.url)
     self.assertIsInstance(e.response, MappingResponse)
     self.assertEquals(200, e.response.status)
     self.assertEquals('test2', e.response.status_message)
     self.assertEquals(False, e.persistent)
     self.assertEquals({'test': '1'}, e.post_serve_actions)
     self.assertEquals('test3', e.new_scenario_state)
     self.assertEquals('test4', e.required_scenario_state)
     self.assertEquals('test5', e.scenario_name)
예제 #3
0
 def retrieve_mapping(cls, mapping_id, parameters={}):
     mapping_id = cls.get_entity_id(mapping_id, Mapping)
     ids = {'id': mapping_id}
     response = cls.REST_CLIENT.get(cls.get_base_uri(
         cls.endpoint_single(), **ids),
                                    headers=make_headers(),
                                    params=parameters)
     response = cls.REST_CLIENT.handle_response(response)
     return Mapping.from_dict(response.json())
예제 #4
0
 def update_mapping(cls, mapping, parameters={}):
     cls.validate_is_entity(mapping, Mapping)
     mapping_id = cls.get_entity_id(mapping, Mapping)
     ids = {'id': mapping_id}
     response = cls.REST_CLIENT.put(cls.get_base_uri(
         cls.endpoint_single(), **ids),
                                    json=mapping.get_json_data(),
                                    headers=make_headers(),
                                    params=parameters)
     response = cls.REST_CLIENT.handle_response(response)
     return Mapping.from_dict(response.json())