def test_from_json_parses_json_string_and_generates_a_configuration_builder():
    json_str = json.dumps({
        'adapter': {
            'module': 'adapter',
            'class': 'Adapter',
            'params': ['foo'],
            'named_params': {
                'foo': 'bar'
            }
        },
        'ignore_tables': ['metainfo'],
        'validations': {
            'module': 'validations'
        }
    })
    assert ConfigurationBuilder.from_json(json_str) == \
        ConfigurationBuilder(
            adapter_module='adapter', adapter_class='Adapter',
            adapter_params=['foo'], adapter_named_params={'foo':'bar'},
            ignore_tables=['metainfo'], validations_module='validations'
        )
Beispiel #2
0
 def _build(adapter_module='test.test_modules.adapter',
            adapter_class='Adapter',
            adapter_params=None,
            adapter_named_params=None,
            validations_module='test.test_modules.validations',
            ignore_tables=None,
            export_format='CLI'):
     return ConfigurationBuilder(adapter_module=adapter_module,
                                 adapter_class=adapter_class,
                                 adapter_params=adapter_params or [],
                                 adapter_named_params=adapter_named_params
                                 or {},
                                 validations_module=validations_module,
                                 ignore_tables=ignore_tables or [],
                                 export_format=export_format)
def test_merging_a_builder_to_an_empty_build_does_not_affect_it():
    configuration_builder = ConfigurationBuilder()
    assert configuration_builder == \
        configuration_builder.merge(ConfigurationBuilder())
def test_from_json_raises_runtime_error_when_it_provides_an_invalid_json():
    with pytest.raises(RuntimeError):
        assert ConfigurationBuilder.from_json('')
def test_from_json_succeeds_even_with_an_empty_config():
    json_str = json.dumps({})
    assert ConfigurationBuilder.from_json(json_str) == ConfigurationBuilder()
def test_build_a_configuration(build_configuration_builder):
    assert ConfigurationBuilder.build(build_configuration_builder())
def test_empty_builder_is_invalid():
    assert ConfigurationBuilder().is_valid() is False