Beispiel #1
0
    def test_top_level_skip_empty_input_single(self):
        class MyService(Service):
            class SimpleIO:
                input = 'aaa', 'bbb', '-ccc', '-ddd', '-eee', '-fff'
                default_value = NotGiven

                class SkipEmpty:
                    input = 'ccc'

        CySimpleIO.attach_sio(self.get_server_config(), MyService)

        data = Bunch()
        data.aaa = 'aaa'
        data.bbb = 'bbb'

        input = MyService._sio.parse_input(data, DATA_FORMAT.JSON)

        self.assertIsInstance(input, Bunch)
        self.assertDictEqual(
            input, {
                'aaa': 'aaa',
                'bbb': 'bbb',
                'ddd': NotGiven,
                'eee': NotGiven,
                'fff': NotGiven,
            })
Beispiel #2
0
    def test_top_level_skip_empty_input_true_no_force_empty_with_attribute(
            self):
        class MyService(Service):
            class SimpleIO:
                input = 'aaa', 'bbb', '-ccc', '-ddd'
                skip_empty_keys = True

        CySimpleIO.attach_sio(self.get_server_config(), MyService)

        data = Bunch()
        data.aaa = 'aaa'
        data.bbb = 'bbb'

        input = MyService._sio.parse_input(data, DATA_FORMAT.JSON)
        self.assertIsInstance(input, Bunch)
        self.assertDictEqual(input, {
            'aaa': 'aaa',
            'bbb': 'bbb',
        })
Beispiel #3
0
    def test_top_level_skip_empty_input_true_with_force_empty_single(self):
        class MyService(Service):
            class SimpleIO:
                input = 'aaa', 'bbb', '-ccc', '-ddd', '-eee', '-fff'

                class SkipEmpty:
                    input = True
                    force_empty_input = 'eee'

        CySimpleIO.attach_sio(self.get_server_config(), MyService)

        data = Bunch()
        data.aaa = 'aaa'
        data.bbb = 'bbb'

        input = MyService._sio.parse_input(data, DATA_FORMAT.JSON)
        self.assertIsInstance(input, Bunch)
        self.assertDictEqual(input, {
            'aaa': 'aaa',
            'bbb': 'bbb',
            'eee': backward_compat_default_value,
        })