def test_encode_wxf_dict(self):
     encoded = encode_api_inputs(
         {"param1": {"k": [1, 2]}, "param2": "foo"}, target_format="wxf"
     )
     self.assertEqual(
         encoded,
         {
             "param1__wxf": b"8:A\x01-S\x01kf\x02s\x04ListC\x01C\x02",
             "param2__wxf": b"8:S\x03foo",
         },
     )
Пример #2
0
 def test_encode_json_dict(self):
     encoded = encode_api_inputs({
         "param1": {
             "k": [1, 2]
         },
         "param2": "foo"
     },
                                 target_format="json")
     self.assertEqual(encoded, {
         "param1__json": '{"k": [1, 2]}',
         "param2__json": '"foo"'
     })
Пример #3
0
 def test_encode_json_dict(self):
     encoded = encode_api_inputs({
         'param1': {
             'k': [1, 2]
         },
         'param2': 'foo'
     },
                                 target_format='json')
     self.assertEqual(encoded, {
         'param1__json': '{"k": [1, 2]}',
         'param2__json': '"foo"'
     })
Пример #4
0
 def test_encode_wxf_dict(self):
     encoded = encode_api_inputs({
         'param1': {
             'k': [1, 2]
         },
         'param2': 'foo'
     },
                                 target_format='wxf')
     self.assertEqual(
         encoded, {
             'param1__wxf': b'8:A\x01-S\x01kf\x02s\x04ListC\x01C\x02',
             'param2__wxf': b'8:S\x03foo'
         })
Пример #5
0
 def test_encode_wl(self):
     encoded = encode_api_inputs({"param1": {"k": [1, 2]}, "param2": "foo"})
     self.assertEqual(encoded, {
         "param1": b'<|"k" -> {1, 2}|>',
         "param2": "foo"
     })
Пример #6
0
 def test_encode_empty_dict(self):
     for target_format in ("wl", "json", "wxf"):
         self.assertEqual(
             encode_api_inputs({}, target_format=target_format), {})
Пример #7
0
 def test_encode_wl(self):
     encoded = encode_api_inputs({'param1': {'k': [1, 2]}, 'param2': 'foo'})
     self.assertEqual(encoded, {
         'param1': b'<|"k" -> {1, 2}|>',
         'param2': 'foo'
     })
Пример #8
0
 def test_encode_empty_dict(self):
     for target_format in ('wl', 'json', 'wxf'):
         self.assertEqual(
             encode_api_inputs({}, target_format=target_format), {})