summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuda Dornelles <dudassdornelles@gmail.com>2015-01-06 17:23:52 -0200
committerPixpoa pairing <pixpoapairing@pixelated-project.org>2015-01-06 17:31:37 -0200
commit4d49a94e35c1a8aa6543cc4534f6e90293a500f0 (patch)
treeb3a34b2f99d096136d9fce262b52eccc642c3154
parent0ff59644d8e804bcab928d184b31a5e6cdc2f6ed (diff)
Getting rid of unused sqlcipher index updates, speeding up tests and app. Also, making the data tests folder a subfolder of soledad-test so that we can make soledad-test into a ramdisk to speed up tests
-rw-r--r--service/pixelated/adapter/services/mail_service.py2
-rw-r--r--service/pixelated/adapter/services/mailboxes.py12
-rw-r--r--service/pixelated/adapter/soledad/soledad_writer_mixin.py24
-rw-r--r--service/test/support/integration/app_test_client.py2
4 files changed, 5 insertions, 35 deletions
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py
index b828222b..3b70890b 100644
--- a/service/pixelated/adapter/services/mail_service.py
+++ b/service/pixelated/adapter/services/mail_service.py
@@ -39,7 +39,7 @@ class MailService:
return mail
def mail(self, mail_id):
- return self.mailboxes.mail(mail_id)
+ return self.querier.mail(mail_id)
def mail_exists(self, mail_id):
return not(not(self.querier.get_header_by_chash(mail_id)))
diff --git a/service/pixelated/adapter/services/mailboxes.py b/service/pixelated/adapter/services/mailboxes.py
index 56304dd6..51d4add9 100644
--- a/service/pixelated/adapter/services/mailboxes.py
+++ b/service/pixelated/adapter/services/mailboxes.py
@@ -47,13 +47,6 @@ class Mailboxes():
def mailboxes(self):
return [self._create_or_get(leap_mailbox_name) for leap_mailbox_name in self.account.mailboxes]
- def mails_by_tag(self, query_tags):
- mails = []
- for mailbox in self.mailboxes():
- mails.extend(mailbox.mails_by_tags(query_tags))
-
- return mails
-
def move_to_trash(self, mail_id):
mail = self.querier.mail(mail_id)
mail.remove_all_tags()
@@ -62,7 +55,4 @@ class Mailboxes():
return mail
def mail(self, mail_id):
- for mailbox in self.mailboxes():
- mail = mailbox.mail(mail_id)
- if mail:
- return mail
+ return self.querier.mail(mail_id)
diff --git a/service/pixelated/adapter/soledad/soledad_writer_mixin.py b/service/pixelated/adapter/soledad/soledad_writer_mixin.py
index 30ca57bd..869f7c07 100644
--- a/service/pixelated/adapter/soledad/soledad_writer_mixin.py
+++ b/service/pixelated/adapter/soledad/soledad_writer_mixin.py
@@ -30,40 +30,20 @@ class SoledadWriterMixin(SoledadDbFacadeMixin, object):
def save_mail(self, mail):
self.put_doc(mail.fdoc)
- self._update_index([mail.fdoc])
def create_mail(self, mail, mailbox_name):
mbox = self.get_mbox(mailbox_name)[0]
uid = mbox.content['lastuid'] + 1
- new_docs = [self.create_doc(doc) for doc in mail.get_for_save(next_uid=uid, mailbox=mailbox_name)]
- fdoc, hdoc, cdocs = new_docs[0], new_docs[1], new_docs[2:len(new_docs)]
- bdoc_index = None
- for i, val in enumerate(cdocs):
- if val.content['phash'] == hdoc.content['body']:
- bdoc_index = i
- bdoc = cdocs.pop(bdoc_index)
+ [self.create_doc(doc) for doc in mail.get_for_save(next_uid=uid, mailbox=mailbox_name)]
mbox.content['lastuid'] = uid
self.put_doc(mbox)
- self._update_index(new_docs)
- return self.mail(mail.ident) # PixelatedMail.from_soledad(fdoc, hdoc, bdoc, parts=None, soledad_querier=self)
+ return self.mail(mail.ident)
def remove_mail(self, mail):
# FIX-ME: Must go through all the part_map phash to delete all the cdocs
self.delete_doc(mail.fdoc)
self.delete_doc(mail.hdoc)
self.delete_doc(mail.bdoc)
-
- def _update_index(self, docs):
- db = self.soledad._db
-
- indexed_fields = db._get_indexed_fields()
- if indexed_fields:
- # It is expected that len(indexed_fields) is shorter than
- # len(raw_doc)
- getters = [(field, db._parse_index_definition(field))
- for field in indexed_fields]
- for doc in docs:
- db._update_indexes(doc.doc_id, doc.content, getters, db._db_handle)
diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py
index 4d444f8d..32d70a66 100644
--- a/service/test/support/integration/app_test_client.py
+++ b/service/test/support/integration/app_test_client.py
@@ -38,7 +38,7 @@ from test.support.integration.model import MailBuilder
class AppTestClient:
- def __init__(self, soledad_test_folder='soledad-test'):
+ def __init__(self, soledad_test_folder='soledad-test/test'):
self.soledad = initialize_soledad(tempdir=soledad_test_folder)
self.mail_address = "test@pixelated.org"