Skip to content

Commit

Permalink
move adapter tests to separate folder / extend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michmuel committed Jan 5, 2024
1 parent c8201ee commit c604bb6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .coveragerc.core_adapter
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
source =
pyramid_oereb/core/adapter.py
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
File renamed without changes.

0 comments on commit c604bb6

Please sign in to comment.