def test_serialize(self):
     config = Config(sections=[
         ConfigSection(
             name='sec1',
             options=[
                 ConfigOption(key='apache', value='airflow'),
                 ConfigOption(key='hello', value='world'),
             ],
         ),
         ConfigSection(name='sec2',
                       options=[
                           ConfigOption(key='foo', value='bar'),
                       ]),
     ])
     result = config_schema.dump(config)
     expected = {
         'sections': [
             {
                 'name':
                 'sec1',
                 'options': [
                     {
                         'key': 'apache',
                         'value': 'airflow'
                     },
                     {
                         'key': 'hello',
                         'value': 'world'
                     },
                 ],
             },
             {
                 'name': 'sec2',
                 'options': [
                     {
                         'key': 'foo',
                         'value': 'bar'
                     },
                 ]
             },
         ]
     }
     assert result == expected
def _config_to_json(config: Config) -> str:
    """Convert a Config object to a JSON formatted string"""
    return json.dumps(config_schema.dump(config), indent=4)