From 787f5360b801eecbebb4d28128c343832b29df57 Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 21 Nov 2017 19:34:34 -0200 Subject: [bug] fix logging while checking CouchDB schema versions on server startup --- tests/couch/test_state.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'tests/couch') diff --git a/tests/couch/test_state.py b/tests/couch/test_state.py index d978fe56..8b06676d 100644 --- a/tests/couch/test_state.py +++ b/tests/couch/test_state.py @@ -1,4 +1,3 @@ -import mock import pytest from leap.soledad.common.couch import CONFIG_DOC_ID @@ -17,7 +16,7 @@ from twisted.internet import reactor from twisted.web.client import HTTPConnectionPool, Agent -class CouchDesignDocsTests(CouchDBTestCase): +class CouchStateTests(CouchDBTestCase): def setUp(self): CouchDBTestCase.setUp(self) @@ -40,14 +39,14 @@ class CouchDesignDocsTests(CouchDBTestCase): self.couch_url, self.db.name, None, agent=self.agent) @defer.inlineCallbacks - def test_check_schema_versions_wrong_schema_version_stops_reactor(self): + def test_check_schema_versions_wrong_schema_version_raises(self): wrong_schema_version = SCHEMA_VERSION + 1 self.db.create( {'_id': CONFIG_DOC_ID, SCHEMA_VERSION_KEY: wrong_schema_version}) - mocked_reactor = mock.Mock() - yield check_schema_versions( - self.couch_url, agent=self.agent, reactor=mocked_reactor) - mocked_reactor.stop.assert_called() + expected_msg = 'Error checking CouchDB schema versions: ' \ + 'FirstError.*WrongCouchSchemaVersionError()' + with pytest.raises(Exception, match=expected_msg): + yield check_schema_versions(self.couch_url, agent=self.agent) @defer.inlineCallbacks def test__check_db_schema_version_missing_config_doc_raises(self): @@ -57,9 +56,9 @@ class CouchDesignDocsTests(CouchDBTestCase): self.couch_url, self.db.name, None, agent=self.agent) @defer.inlineCallbacks - def test_check_schema_versions_missing_config_doc_stops_reactor(self): + def test_check_schema_versions_missing_config_doc_raises(self): self.db.create({}) - mocked_reactor = mock.Mock() - yield check_schema_versions( - self.couch_url, agent=self.agent, reactor=mocked_reactor) - mocked_reactor.stop.assert_called() + expected_msg = 'Error checking CouchDB schema versions: ' \ + 'FirstError.*MissingCouchConfigDocumentError()' + with pytest.raises(Exception, match=expected_msg): + yield check_schema_versions(self.couch_url, agent=self.agent) -- cgit v1.2.3