def xtest_set_payload_direct_payload_case_2a(self): # basestring, dict, list, tuple, bool, Number + (EtreeElement, ObjectifiedElement) data_01 = b'abc' data_02 = u'def' data_03 = [1, 2, 3] data_04 = (5, 6, 7) data_05 = True data_06 = False data_07 = 1 data_08 = 2.0 data_09 = EtreeElement() data_10 = ObjectifiedElement() elems = [ data_01, data_02, data_03, data_04, data_05, data_06, data_07, data_08, data_09, data_10 ] response = Response() response.init('abc', None, DATA_FORMAT.CSV) for elem in elems: response.payload = elem self.assertIs(response.payload, elem)
def xtest_set_payload_dict_no_sio_case_1b(self): response = Response() response.init('abc', None, DATA_FORMAT.CSV) data = {'a': 'aa', 'b': 'bb'} response.payload = data self.assertDictEqual(response.payload, data)
def _prepare_sio_response(self, data, data_format, is_list): # type: (object, str, bool) -> str MyService = deepcopy(MyODBService) CySimpleIO.attach_sio(self.get_server_config(False), MyService) response = Response() response.init('abc', MyService._sio, data_format) if is_list: response.payload[:] = data else: response.payload = data return response.payload.getvalue()
def xtest_set_payload_not_direct_payload_no_sio_case_2b2(self): class MyCustomPayloadType: def __repr__(self): return '<MyCustomPayloadType>' response = Response() response.init('abc', None, DATA_FORMAT.CSV) try: response.payload = MyCustomPayloadType() except Exception as e: self.assertEqual( e.args[0], 'Cannot serialise value without SimpleIO ouput declaration (<MyCustomPayloadType>)' ) else: self.fail('Expected for an exception to be raised')
def xtest_set_payload_dict_has_sio_case_1a(self): MyService = deepcopy(MyBaseService) CySimpleIO.attach_sio(self.get_server_config(), MyService) response = Response() response.init('abc', MyService._sio, DATA_FORMAT.XML) # Note that 'ddd' is optional so it can be missing # and that 'fff' is not in SIO so it should be ignored. data = { 'aaa': '111', 'bbb': '222', 'ccc': '333', 'eee': '555', 'fff': '666', 'qqq': 777, 'www': 888 } response.payload = data