diff --git a/tests/core/test_config.py b/tests/core/test_config.py index e29eee5abd..50665d0c65 100644 --- a/tests/core/test_config.py +++ b/tests/core/test_config.py @@ -110,9 +110,25 @@ def mock_read_logos(): assert Config.logos is None @pytest.mark.parametrize('test_logos_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.logo.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Logo"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.logo.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Logo"}}},1), - ]) + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.logo.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Logo" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.logo.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Logo" + } + } + },1) +]) @pytest.mark.run(order=-1) def test_read_logos(test_logos_config,expected_result): Config._config = None @@ -223,10 +239,27 @@ def test_get_theme_config_by_code_none(): with pytest.raises(AssertionError): Config.get_theme_config_by_code('ch.NE.Baulinien') + @pytest.mark.parametrize('test_themes_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.theme.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Theme"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.theme.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Theme"}}},1), - ]) + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.theme.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Theme" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.theme.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Theme" + } + } + },1) +]) @pytest.mark.run(order=-1) def test_read_themes(test_themes_config,expected_result): Config._config = None @@ -234,6 +267,7 @@ def test_read_themes(test_themes_config,expected_result): with patch.object(ThemeReader, 'read', return_value=[None] * expected_result): assert len(Config._read_themes()) == expected_result + @pytest.mark.run(order=-1) def test_read_themes_config_none(): Config._config = None @@ -241,9 +275,26 @@ def test_read_themes_config_none(): with pytest.raises(ConfigurationError): Config._read_themes() + @pytest.mark.parametrize('test_theme_document_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.theme_document.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.ThemeDocument"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.theme_document.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.ThemeDocument"}}},1), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.theme_document.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.ThemeDocument" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.theme_document.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.ThemeDocument" + } + } + },1) ]) @pytest.mark.run(order=-1) def test_read_theme_document(test_theme_document_config,expected_result): @@ -252,6 +303,7 @@ def test_read_theme_document(test_theme_document_config,expected_result): with patch.object(ThemeDocumentReader, 'read', return_value=[None] * expected_result): assert len(Config._read_theme_document()) == expected_result + @pytest.mark.run(order=-1) def test_read_theme_document_config_none(): Config._config = None @@ -259,6 +311,7 @@ def test_read_theme_document_config_none(): with pytest.raises(ConfigurationError): Config._read_theme_document() + @pytest.mark.parametrize('test_value,expected_value', [ ({'real_estate_type': {}}, {}), ({'not_expecting_key': {}}, None) @@ -381,10 +434,27 @@ def test_get_extract_config_none(): with pytest.raises(AssertionError): Config.get_extract_config() + @pytest.mark.parametrize('test_general_information_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.general_information.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.GeneralInformation"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.general_information.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.GeneralInformation"}}},1), - ]) + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.general_information.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.GeneralInformation" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.general_information.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.GeneralInformation" + } + } + },1) +]) @pytest.mark.run(order=-1) def test_read_general_information(test_general_information_config,expected_result): Config._config = None @@ -392,6 +462,7 @@ def test_read_general_information(test_general_information_config,expected_resul with patch.object(GeneralInformationReader, 'read', return_value=[None] * expected_result): assert len(Config._read_general_information()) == expected_result + @pytest.mark.run(order=-1) def test_read_general_information_config_none(): Config._config = None @@ -399,10 +470,28 @@ def test_read_general_information_config_none(): with pytest.raises(ConfigurationError): Config._read_general_information() + @pytest.mark.parametrize('test_law_status_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.law_status.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.LawStatus"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.law_status.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.LawStatus"}}},1), - ]) + ({ + "source": { + "class": + "pyramid_oereb.contrib.data_sources.standard.sources.law_status.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.LawStatus" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.law_status.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.LawStatus" + } + } + },1) +]) @pytest.mark.run(order=-1) def test_read_law_status(test_law_status_config,expected_result): Config._config = None @@ -410,6 +499,7 @@ def test_read_law_status(test_law_status_config,expected_result): with patch.object(LawStatusReader, 'read', return_value=[None] * expected_result): assert len(Config._read_law_status()) == expected_result + @pytest.mark.run(order=-1) def test_read_law_status_config_none(): Config._config = None @@ -417,10 +507,29 @@ def test_read_law_status_config_none(): with pytest.raises(ConfigurationError): Config._read_law_status() + @pytest.mark.parametrize('test_documents_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.document.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Document"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.document.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Document"}}},1), - ]) + ({ + "source": { + "class": + "pyramid_oereb.contrib.data_sources.standard.sources.document.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Document" + } + } + },0), + ({ + "source": { + "class": + "pyramid_oereb.contrib.data_sources.standard.sources.document.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Document" + } + } + },1) +]) @pytest.mark.run(order=-1) def test_read_documents(test_documents_config,expected_result): Config._config = None @@ -428,6 +537,7 @@ def test_read_documents(test_documents_config,expected_result): with patch.object(DocumentReader, 'read', return_value=[None] * expected_result): assert len(Config._read_documents()) == expected_result + @pytest.mark.run(order=-1) def test_read_documents_config_none(): Config._config = None @@ -435,10 +545,27 @@ def test_read_documents_config_none(): with pytest.raises(ConfigurationError): Config._read_documents() + @pytest.mark.parametrize('test_offices_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.office.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Office"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.office.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Office"}}},1), - ]) + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.office.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Office" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.office.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Office" + } + } + },1), +]) @pytest.mark.run(order=-1) def test_read_offices(test_offices_config,expected_result): Config._config = None @@ -446,6 +573,7 @@ def test_read_offices(test_offices_config,expected_result): with patch.object(OfficeReader, 'read', return_value=[None] * expected_result): assert len(Config._read_offices()) == expected_result + @pytest.mark.run(order=-1) def test_read_offices_config_none(): Config._config = None @@ -453,10 +581,27 @@ def test_read_offices_config_none(): with pytest.raises(ConfigurationError): Config._read_offices() + @pytest.mark.parametrize('test_availability_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.availability.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Availability"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.availability.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Availability"}}},1), - ]) + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.availability.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Availability" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.availability.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Availability" + } + } + },1) +]) @pytest.mark.run(order=-1) def test_read_availabilities(test_availability_config,expected_result): Config._config = None @@ -464,6 +609,7 @@ def test_read_availabilities(test_availability_config,expected_result): with patch.object(AvailabilityReader, 'read', return_value=[None] * expected_result): assert len(Config._read_availabilities()) == expected_result + @pytest.mark.run(order=-1) def test_read_availabilities_config_none(): Config._config = None @@ -471,10 +617,27 @@ def test_read_availabilities_config_none(): with pytest.raises(ConfigurationError): Config._read_availabilities() + @pytest.mark.parametrize('test_glossary_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.glossary.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Glossary"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.glossary.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Glossary"}}},1), - ]) + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.glossary.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Glossary" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.glossary.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Glossary" + } + } + },1) +]) @pytest.mark.run(order=-1) def test_read_glossaries(test_glossary_config,expected_result): Config._config = None @@ -482,6 +645,7 @@ def test_read_glossaries(test_glossary_config,expected_result): with patch.object(GlossaryReader, 'read', return_value=[None] * expected_result): assert len(Config._read_glossaries()) == expected_result + @pytest.mark.run(order=-1) def test_read_glossaries_config_none(): Config._config = None @@ -489,10 +653,27 @@ def test_read_glossaries_config_none(): with pytest.raises(ConfigurationError): Config._read_glossaries() + @pytest.mark.parametrize('test_disclaimer_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.disclaimer.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Disclaimer"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.disclaimer.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Disclaimer"}}},1), - ]) + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.disclaimer.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Disclaimer" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.disclaimer.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Disclaimer" + } + } + },1), +]) @pytest.mark.run(order=-1) def test_read_disclaimers(test_disclaimer_config,expected_result): Config._config = None @@ -500,6 +681,7 @@ def test_read_disclaimers(test_disclaimer_config,expected_result): with patch.object(DisclaimerReader, 'read', return_value=[None] * expected_result): assert len(Config._read_disclaimers()) == expected_result + @pytest.mark.run(order=-1) def test_read_disclaimers_config_none(): Config._config = None @@ -507,10 +689,27 @@ def test_read_disclaimers_config_none(): with pytest.raises(ConfigurationError): Config._read_disclaimers() + @pytest.mark.parametrize('test_municipality_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.municipality.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Municipality"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.municipality.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.Municipality"}}},1), - ]) + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.municipality.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Municipality" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.municipality.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.Municipality" + } + } + },1) +]) @pytest.mark.run(order=-1) def test_read_municipalities(test_municipality_config,expected_result): Config._config = None @@ -518,6 +717,7 @@ def test_read_municipalities(test_municipality_config,expected_result): with patch.object(MunicipalityReader, 'read', return_value=[None] * expected_result): assert len(Config._read_municipalities()) == expected_result + @pytest.mark.run(order=-1) def test_read_municipalities_config_none(): Config._config = None @@ -525,10 +725,27 @@ def test_read_municipalities_config_none(): with pytest.raises(ConfigurationError): Config._read_municipalities() + @pytest.mark.parametrize('test_document_types_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.document_types.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.DocumentTypeText"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.document_types.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.DocumentTypeText"}}},1), - ]) + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.document_types.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.DocumentTypeText" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.document_types.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.DocumentTypeText" + } + } + },1) +]) @pytest.mark.run(order=-1) def test_read_document_types(test_document_types_config,expected_result): Config._config = None @@ -536,6 +753,7 @@ def test_read_document_types(test_document_types_config,expected_result): with patch.object(DocumentTypeReader, 'read', return_value=[None] * expected_result): assert len(Config._read_document_types()) == expected_result + @pytest.mark.run(order=-1) def test_read_document_types_config_none(): Config._config = None @@ -543,10 +761,27 @@ def test_read_document_types_config_none(): with pytest.raises(ConfigurationError): Config._read_document_types() + @pytest.mark.parametrize('test_real_estate_type_config,expected_result', [ - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.real_estate_type.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.RealEstateType"}}},0), - ({"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.real_estate_type.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.RealEstateType"}}},1), - ]) + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.real_estate_type.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.RealEstateType" + } + } + },0), + ({ + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.real_estate_type.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.RealEstateType" + } + } + },1) +]) @pytest.mark.run(order=-1) def test_read_real_estate_types(test_real_estate_type_config,expected_result): Config._config = None @@ -554,6 +789,7 @@ def test_read_real_estate_types(test_real_estate_type_config,expected_result): with patch.object(RealEstateTypeReader, 'read', return_value=[None] * expected_result): assert len(Config._read_real_estate_types()) == expected_result + @pytest.mark.run(order=-1) def test_read_real_estate_types_config_none(): Config._config = None @@ -561,10 +797,31 @@ def test_read_real_estate_types_config_none(): with pytest.raises(ConfigurationError): Config._read_real_estate_types() + @pytest.mark.parametrize('test_map_layering_config,expected_result', [ - ({"map_layering": {"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.map_layering.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.MapLayering"}}}},0), - ({"map_layering": {"source": {"class": "pyramid_oereb.contrib.data_sources.standard.sources.map_layering.DatabaseSource","params": {"db_connection": "*main_db_connection","model": "pyramid_oereb.contrib.data_sources.standard.models.main.MapLayering"}}}},1), - ]) + ({ + "map_layering": { + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.map_layering.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.MapLayering" + } + } + } + },0), + ({ + "map_layering": { + "source": { + "class": "pyramid_oereb.contrib.data_sources.standard.sources.map_layering.DatabaseSource", + "params": { + "db_connection": "*main_db_connection", + "model": "pyramid_oereb.contrib.data_sources.standard.models.main.MapLayering" + } + } + } + },1) +]) @pytest.mark.run(order=-1) def test_read_map_layering(test_map_layering_config,expected_result): Config._config = None @@ -572,8 +829,9 @@ def test_read_map_layering(test_map_layering_config,expected_result): with patch.object(MapLayeringReader, 'read', return_value=[None] * expected_result): assert len(Config._read_map_layering()) == expected_result + @pytest.mark.run(order=-1) def test_read_map_layering_config_none(): Config._config = {} with pytest.raises(ConfigurationError): - Config._read_map_layering() \ No newline at end of file + Config._read_map_layering()