Beispiel #1
0
    def set_data(self, public_key, data):
        user_address = addresser.get_user_address(public_key)

        data_pb = data_pb2.Data(
            data=data
        )
        container = data_pb2.DataContainer()
        state_entries = self._context.get_state(
            addresses=[user_address], timeout=self._timeout)
        if state_entries:
            container.ParseFromString(state_entries[0].data)

        container.entries.extend([data_pb])
        data = container.SerializeToString()
        updated_state = {}
        updated_state[user_address] = data
        self._context.set_state(updated_state, timeout=self._timeout)
 def test_5_data_combination(self):
     args = data_pb2.Data()
     args.text = 'A_a$%B_b&*_中文_|{ ]~'
     response = self.client.DoFormat(args)
     print(response.text)
     self.assertEqual(response.text, 'A_A$%B_B&*_中文_|{ ]~')
 def test_4_data_Spechars(self):
     args = data_pb2.Data()
     args.text = '><?$%&*|{]~'
     response = self.client.DoFormat(args)
     print(response.text)
     self.assertEqual(response.text, '><?$%&*|{]~')
 def test_3_data_Chinese(self):
     args = data_pb2.Data()
     args.text = '我是中文'
     response = self.client.DoFormat(args)
     print(response.text)
     self.assertEqual(response.text, '我是中文')
 def test_2_data_null(self):
     args = data_pb2.Data()
     args.text = ''
     response = self.client.DoFormat(args)
     print(response.text)
     self.assertEqual(response.text, '')
 def test_1_lower_letters(self):
     args = data_pb2.Data()
     args.text = 'Convert to uppercase successfully'
     response = self.client.DoFormat(args)
     print(response.text)
     self.assertEqual(response.text, 'CONVERT TO UPPERCASE SUCCESSFULLY')