diff --git a/.coveragerc.core_adapter b/.coveragerc.core_adapter new file mode 100644 index 0000000000..49ee4ae2f0 --- /dev/null +++ b/.coveragerc.core_adapter @@ -0,0 +1,3 @@ +[run] +source = + pyramid_oereb/core/adapter.py diff --git a/.gitignore b/.gitignore index 803fb3fec7..5528c6d517 100644 --- a/.gitignore +++ b/.gitignore @@ -84,5 +84,6 @@ DataExtract.json /coverage.contrib-print_proxy-mapfish_print.xml /coverage.contrib-data_sources-swisstopo.xml /coverage.core.xml +/coverage.core_adapter.xml /coverage.contrib-stats.xml /coverage.xml diff --git a/Makefile b/Makefile index 8ce74694b0..a59a7c558b 100644 --- a/Makefile +++ b/Makefile @@ -305,6 +305,10 @@ test-postgis: test-core: ${VENV_ROOT}/requirements-timestamp $(VENV_BIN)/py.test -vv $(PYTEST_OPTS) --cov-config .coveragerc.core --cov $(PACKAGE)/core --cov-report=term-missing --cov-report=xml:coverage.core.xml tests/core +.PHONY: test-core_adapter +test-core_adapter: ${VENV_ROOT}/requirements-timestamp + $(VENV_BIN)/py.test -vv $(PYTEST_OPTS) --cov-config .coveragerc.core_adapter --cov $(PACKAGE)/core --cov-report=term-missing --cov-report=xml:coverage.core_adapter.xml tests/core_adapter + .PHONY: test-contrib-print_proxy-mapfish_print test-contrib-print_proxy-mapfish_print: ${VENV_ROOT}/requirements-timestamp $(VENV_BIN)/py.test -vv $(PYTEST_OPTS) --cov-config .coveragerc.contrib-print_proxy-mapfish_print --cov $(PACKAGE) --cov-report xml:coverage.contrib-print_proxy-mapfish_print.xml tests/contrib.print_proxy.mapfish_print @@ -327,7 +331,7 @@ test-contrib-stats: ${VENV_ROOT}/requirements-timestamp $(VENV_BIN)/py.test -vv $(PYTEST_OPTS) --cov-config .coveragerc.contrib-stats --cov $(PACKAGE)/contrib/stats --cov-report=xml:coverage.contrib-stats.xml tests/contrib.stats .PHONY: tests -tests: ${VENV_ROOT}/requirements-timestamp test-core test-contrib-print_proxy-mapfish_print test-contrib-data_sources-standard test-contrib-data_sources-interlis test-contrib-stats test-contrib-data_sources-swisstopo +tests: ${VENV_ROOT}/requirements-timestamp test-core test-core_adapter test-contrib-print_proxy-mapfish_print test-contrib-data_sources-standard test-contrib-data_sources-interlis test-contrib-stats test-contrib-data_sources-swisstopo .PHONY: docker-tests docker-tests: diff --git a/tests/core/test_adapter_database.py b/tests/core_adapter/test_adapter_database.py similarity index 88% rename from tests/core/test_adapter_database.py rename to tests/core_adapter/test_adapter_database.py index 68ddad75f3..5914240883 100644 --- a/tests/core/test_adapter_database.py +++ b/tests/core_adapter/test_adapter_database.py @@ -9,7 +9,7 @@ def test_init(): assert isinstance(adapter._connections_, dict) -def test_get_connections(): +def test_get_connections_instance(): adapter = DatabaseAdapter() assert isinstance(adapter.get_connections(), dict) @@ -43,15 +43,19 @@ def test_get_session_that_exists(): db_url = 'postgresql://adapter_user:adapter_pswd@adapter-tests-03:5432/adapter-db' adapter = DatabaseAdapter() adapter.add_connection(db_url) + n_connections = len(adapter.get_connections()) assert adapter.get_connections().get(db_url) is not None session_00 = adapter.get_session(db_url) assert isinstance(session_00, Session) + assert len(adapter.get_connections()) == n_connections def test_get_session_that_does_not_exists(): db_url = 'postgresql://adapter_user:adapter_pswd@adapter-tests-04:5432/adapter-db' adapter = DatabaseAdapter() + n_connections = len(adapter.get_connections()) assert adapter.get_connections().get(db_url, None) is None session_00 = adapter.get_session(db_url) assert adapter.get_connections().get(db_url, None) is not None assert isinstance(session_00, Session) + assert len(adapter.get_connections()) == (n_connections + 1) diff --git a/tests/core/test_adapter_file.py b/tests/core_adapter/test_adapter_file.py similarity index 100% rename from tests/core/test_adapter_file.py rename to tests/core_adapter/test_adapter_file.py