diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-06-12 15:48:04 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-06-12 15:48:04 -0300 |
commit | 42aa76d8463ffe73d5e22d178f8414cfdbd2730e (patch) | |
tree | 1a7a4377b8c91d495d3755f3ebe6d3f8bb10dcce /service | |
parent | 761f4c1232601cb22ce57c38b904c0866f31c577 (diff) |
[refactor] SearchEngine does not need a querier
It was used only to retrieve encryption key. This should be done by who
is using it.
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/adapter/search/__init__.py | 7 | ||||
-rw-r--r-- | service/pixelated/config/services.py | 3 | ||||
-rw-r--r-- | service/test/support/integration/app_test_client.py | 2 | ||||
-rw-r--r-- | service/test/unit/adapter/search/test_search.py | 6 |
4 files changed, 7 insertions, 11 deletions
diff --git a/service/pixelated/adapter/search/__init__.py b/service/pixelated/adapter/search/__init__.py index da8845cc..b8d3e7ca 100644 --- a/service/pixelated/adapter/search/__init__.py +++ b/service/pixelated/adapter/search/__init__.py @@ -35,8 +35,8 @@ class SearchEngine(object): DEFAULT_INDEX_HOME = os.path.join(os.environ['HOME'], '.leap') DEFAULT_TAGS = ['inbox', 'sent', 'drafts', 'trash'] - def __init__(self, soledad_querier, agent_home=DEFAULT_INDEX_HOME): - self.soledad_querier = soledad_querier + def __init__(self, key, agent_home=DEFAULT_INDEX_HOME): + self.key = key self.index_folder = os.path.join(agent_home, 'search_index') if not os.path.exists(self.index_folder): os.makedirs(self.index_folder) @@ -111,8 +111,7 @@ class SearchEngine(object): raw=TEXT(stored=False)) def _create_index(self): - masterkey = self.soledad_querier.get_index_masterkey() - storage = EncryptedFileStorage(self.index_folder, masterkey) + storage = EncryptedFileStorage(self.index_folder, self.key) return FileIndex.create(storage, self._mail_schema(), indexname='mails') def index_mail(self, mail): diff --git a/service/pixelated/config/services.py b/service/pixelated/config/services.py index 5cab0985..b6de3f40 100644 --- a/service/pixelated/config/services.py +++ b/service/pixelated/config/services.py @@ -45,7 +45,8 @@ class Services(object): return leap_session.nicknym.keymanager def setup_search_engine(self, leap_home, soledad_querier): - search_engine = SearchEngine(soledad_querier, agent_home=leap_home) + key = self.soledad_querier.get_index_masterkey() + search_engine = SearchEngine(key, agent_home=leap_home) MailboxIndexerListener.SEARCH_ENGINE = search_engine return search_engine diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index 06c0fd9c..52372507 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -62,7 +62,7 @@ class AppTestClient(object): self.soledad_querier = self._create_soledad_querier(self.soledad, self.INDEX_KEY) self.keymanager = mock() - self.search_engine = SearchEngine(self.soledad_querier, agent_home=soledad_test_folder) + self.search_engine = SearchEngine(self.INDEX_KEY, agent_home=soledad_test_folder) self.mail_sender = self._create_mail_sender() self.account = SoledadBackedAccount(self.ACCOUNT, self.soledad, MagicMock()) diff --git a/service/test/unit/adapter/search/test_search.py b/service/test/unit/adapter/search/test_search.py index 491cb2fc..1d9076a2 100644 --- a/service/test/unit/adapter/search/test_search.py +++ b/service/test/unit/adapter/search/test_search.py @@ -16,7 +16,6 @@ import unittest -from mockito import mock, when from pixelated.adapter.search import SearchEngine from tempdir import TempDir from test.support import test_helper @@ -47,10 +46,7 @@ class SearchEngineTest(unittest.TestCase): def test_encoding(self): # given - soledad_querier = mock() - when(soledad_querier).get_index_masterkey().thenReturn(INDEX_KEY) - - se = SearchEngine(soledad_querier, self.agent_home) + se = SearchEngine(INDEX_KEY, self.agent_home) headers = { 'From': 'foo@bar.tld', |