diff options
-rw-r--r-- | service/pixelated/adapter/search/__init__.py | 4 | ||||
-rw-r--r-- | service/pixelated/config/services.py | 5 | ||||
-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, 9 insertions, 8 deletions
diff --git a/service/pixelated/adapter/search/__init__.py b/service/pixelated/adapter/search/__init__.py index 1c06f66c..27563c03 100644 --- a/service/pixelated/adapter/search/__init__.py +++ b/service/pixelated/adapter/search/__init__.py @@ -36,9 +36,9 @@ class SearchEngine(object): DEFAULT_INDEX_HOME = os.path.join(os.environ['HOME'], '.leap') DEFAULT_TAGS = ['inbox', 'sent', 'drafts', 'trash'] - def __init__(self, key, agent_home=DEFAULT_INDEX_HOME): + def __init__(self, key, namespace, agent_home=DEFAULT_INDEX_HOME): self.key = key - self.index_folder = os.path.join(agent_home, 'search_index') + self.index_folder = os.path.join(agent_home, 'search_index', namespace) if not os.path.exists(self.index_folder): os.makedirs(self.index_folder) self._index = self._create_index() diff --git a/service/pixelated/config/services.py b/service/pixelated/config/services.py index b8b355b0..0b9b98df 100644 --- a/service/pixelated/config/services.py +++ b/service/pixelated/config/services.py @@ -23,6 +23,7 @@ class Services(object): search_index_storage_key = self.setup_search_index_storage_key(leap_session.soledad) yield self.setup_search_engine( leap_home, + leap_session.user_auth.uuid, search_index_storage_key) self.wrap_mail_store_with_indexing_mail_store(leap_session) @@ -48,11 +49,11 @@ class Services(object): self.search_engine.index_mails(all_mails) @defer.inlineCallbacks - def setup_search_engine(self, leap_home, search_index_storage_key): + def setup_search_engine(self, leap_home, namespace, search_index_storage_key): key_unicode = yield search_index_storage_key.get_or_create_key() key = str(key_unicode) print 'The key len is: %s' % len(key) - search_engine = SearchEngine(key, agent_home=leap_home) + search_engine = SearchEngine(key, namespace, agent_home=leap_home) self.search_engine = search_engine def setup_mail_service(self, leap_session, search_engine): diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index 89f42532..894aec2d 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -67,7 +67,7 @@ class AppTestClient(object): self.keymanager = mock() - self.search_engine = SearchEngine(self.INDEX_KEY, agent_home=soledad_test_folder) + self.search_engine = SearchEngine(self.INDEX_KEY, 'test_namespace', agent_home=soledad_test_folder) self.mail_sender = self._create_mail_sender() self.mail_store = SearchableMailStore(LeapMailStore(self.soledad), self.search_engine) diff --git a/service/test/unit/adapter/search/test_search.py b/service/test/unit/adapter/search/test_search.py index 2583352c..654524f5 100644 --- a/service/test/unit/adapter/search/test_search.py +++ b/service/test/unit/adapter/search/test_search.py @@ -50,7 +50,7 @@ class SearchEngineTest(unittest.TestCase): def test_headers_encoding(self): # given - se = SearchEngine(INDEX_KEY, self.agent_home) + se = SearchEngine(INDEX_KEY, 'test_namespace', self.agent_home) headers = { 'From': 'foo@bar.tld', @@ -68,7 +68,7 @@ class SearchEngineTest(unittest.TestCase): def test_contents_encoding_accents(self): # given - se = SearchEngine(INDEX_KEY, self.agent_home) + se = SearchEngine(INDEX_KEY, 'test_namespace', self.agent_home) headers = { 'From': 'foo@bar.tld', @@ -93,7 +93,7 @@ class SearchEngineTest(unittest.TestCase): def test_contents_encoding_special_characters(self): # given - se = SearchEngine(INDEX_KEY, self.agent_home) + se = SearchEngine(INDEX_KEY, 'test_namespace', self.agent_home) headers = { 'From': 'foo@bar.tld', |