From 333bcf1c40f843e8b5c55c82cbf4cafe0fcaab30 Mon Sep 17 00:00:00 2001 From: rich-hart Date: Mon, 16 Feb 2015 10:33:34 -0600 Subject: [PATCH] Adding coverage configuration file. --- .coveragerc | 19 +++++++++++++++++++ cnxauthoring/storage/postgresql.py | 5 ++++- .../tests/test_storage/test_postgresql.py | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..524270f --- /dev/null +++ b/.coveragerc @@ -0,0 +1,19 @@ +# .coveragerc to control coverage.py +[run] +branch = True + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain about missing debug-only code: + + # Don't complain if tests don't hit defensive assertion code: + raise NotImplementedError + +ignore_errors = True + +[html] +directory = coverage_html_report diff --git a/cnxauthoring/storage/postgresql.py b/cnxauthoring/storage/postgresql.py index 3a413f3..04c29b8 100644 --- a/cnxauthoring/storage/postgresql.py +++ b/cnxauthoring/storage/postgresql.py @@ -59,8 +59,11 @@ class PostgresqlStorage(BaseStorage): Error = psycopg2.Error def __init__(self, db_connection_string=None): - #initialize db + # initialize db self.conn = psycopg2.connect(db_connection_string) + # adding a variable to store the db_connection string + # needed to restart the database when a connection + # is broken or lost. self.db_connection_string = db_connection_string def get(self, type_=Document, **kwargs): diff --git a/cnxauthoring/tests/test_storage/test_postgresql.py b/cnxauthoring/tests/test_storage/test_postgresql.py index fba3d64..8d3d3a2 100644 --- a/cnxauthoring/tests/test_storage/test_postgresql.py +++ b/cnxauthoring/tests/test_storage/test_postgresql.py @@ -82,6 +82,10 @@ def test_add_get_and_remove_binder(self): {'user2': ('view',)}) def test_restart(self): + """ + Testing PostrgressStorage class restart function + with a password connection string. + """ from ...storage.database import CONNECTION_SETTINGS_KEY import psycopg2 settings = integration_test_settings()