コード例 #1
0
    def test_convert_prog_descriptions_without_config(self) -> None:
        with local_app.app_context():
            # mock config
            test_config = None
            # test data
            test_desc = [
                {
                    'source': 'test4',
                    'text': 'test'
                },
                {
                    'source': 'test5',
                    'text': 'test'
                },
            ]
            # expected order based on mock
            expected_programmatic_desc = {
                'other': [
                    {
                        'source': 'test4',
                        'text': 'test'
                    },
                    {
                        'source': 'test5',
                        'text': 'test'
                    },
                ]
            }
            local_app.config['PROGRAMMATIC_DISPLAY'] = test_config

            result = _convert_prog_descriptions(test_desc)
            self.assertEqual(len(result['left']), 0)
            self.assertEqual(len(result['right']), 0)
            self.assertEqual(result.get('other'),
                             expected_programmatic_desc.get('other'))
コード例 #2
0
    def test_convert_prog_descriptions(self) -> None:
        with local_app.app_context():
            # mock config
            test_config = {
                'RIGHT': {
                    'test3': {},
                    'test2': {
                        'display_order': 0
                    },
                },
                'LEFT': {
                    'test1': {
                        'display_order': 1
                    },
                    'test0': {
                        'display_order': 0
                    },
                },
                'test4': {
                    'display_order': 0
                },
            }
            # test data
            test_desc = [
                {
                    'source': 'test0',
                    'text': 'test'
                },
                {
                    'source': 'test1',
                    'text': 'test'
                },
                {
                    'source': 'test2',
                    'text': 'test'
                },
                {
                    'source': 'test3',
                    'text': 'test'
                },
                {
                    'source': 'test5',
                    'text': 'test'
                },
                {
                    'source': 'test4',
                    'text': 'test'
                },
            ]
            # expected order based on mock
            expected_programmatic_desc = {
                'left': [
                    {
                        'source': 'test0',
                        'text': 'test'
                    },
                    {
                        'source': 'test1',
                        'text': 'test'
                    },
                ],
                'right': [
                    {
                        'source': 'test2',
                        'text': 'test'
                    },
                    {
                        'source': 'test3',
                        'text': 'test'
                    },
                ],
                'other': [
                    {
                        'source': 'test4',
                        'text': 'test'
                    },
                    {
                        'source': 'test5',
                        'text': 'test'
                    },
                ]
            }
            local_app.config['PROGRAMMATIC_DISPLAY'] = test_config

            result = _convert_prog_descriptions(test_desc)
            self.assertEqual(result.get('left'),
                             expected_programmatic_desc.get('left'))
            self.assertEqual(result.get('right'),
                             expected_programmatic_desc.get('right'))
            self.assertEqual(result.get('other'),
                             expected_programmatic_desc.get('other'))