summaryrefslogtreecommitdiff
path: root/py-fake-service
diff options
context:
space:
mode:
authorBruno Wagner Goncalves <bwagner@thoughtworks.com>2014-08-18 16:50:02 -0300
committerBruno Wagner Goncalves <bwagner@thoughtworks.com>2014-08-18 16:56:44 -0300
commit9900ee2ec6b52d8887f00c4d39d0ff30a2714421 (patch)
tree07abc917968d5477c2c9b905461435bc07b059cb /py-fake-service
parent693f2213bc0d34f85beee36709323651cffd2263 (diff)
Fixed PEP8 issues on py fake service
Diffstat (limited to 'py-fake-service')
-rw-r--r--py-fake-service/app/adapter/contacts.py6
-rw-r--r--py-fake-service/app/adapter/mailset.py5
-rw-r--r--py-fake-service/app/pixelated_user_agent.py6
-rw-r--r--py-fake-service/app/search/search_query.py7
4 files changed, 16 insertions, 8 deletions
diff --git a/py-fake-service/app/adapter/contacts.py b/py-fake-service/app/adapter/contacts.py
index aaf2d23e..5c55b8b1 100644
--- a/py-fake-service/app/adapter/contacts.py
+++ b/py-fake-service/app/adapter/contacts.py
@@ -13,8 +13,10 @@ class Contacts:
def search(self, query):
contacts_query = re.compile(query)
return [
- contact.__dict__ for contact in self.contacts if contacts_query.match(
- contact.addresses[0])]
+ contact.__dict__
+ for contact in self.contacts
+ if contacts_query.match(contact.addresses[0])
+ ]
class Contact:
diff --git a/py-fake-service/app/adapter/mailset.py b/py-fake-service/app/adapter/mailset.py
index d08a58cb..2d9707ab 100644
--- a/py-fake-service/app/adapter/mailset.py
+++ b/py-fake-service/app/adapter/mailset.py
@@ -22,7 +22,10 @@ class MailSet:
mail.status.append('read')
def delete(self, mail_id):
- """ Returns True if the email got purged, else returns False meaning the email got moved to trash """
+ """
+ Returns True if the email got purged,
+ else returns False meaning the email got moved to trash
+ """
mail = self.get(mail_id)
if 'trash' in mail.tags:
diff --git a/py-fake-service/app/pixelated_user_agent.py b/py-fake-service/app/pixelated_user_agent.py
index 7d974329..41407b1c 100644
--- a/py-fake-service/app/pixelated_user_agent.py
+++ b/py-fake-service/app/pixelated_user_agent.py
@@ -7,6 +7,8 @@ from adapter import MailService
from search import SearchQuery
app = Flask(__name__, static_url_path='', static_folder='../../web-ui/app')
+MEDIUM_TAGGED_URL = 'https://example.wazokazi.is:8154\
+ /go/static/py-mediumtagged.tar.gz'
client = None
converter = None
account = None
@@ -119,9 +121,7 @@ def load_mailset(mailset):
os.mkdir(mbox_root)
if len(os.listdir(mbox_root)) == 0:
- response = requests.get(
- 'https://example.wazokazi.is:8154/go/static/py-mediumtagged.tar.gz',
- verify=False)
+ response = requests.get(MEDIUM_TAGGED_URL, verify=False)
mbox_archive_path = os.path.join(mbox_root, 'py-mediumtagged.tar.gz')
mbox_archive = open(mbox_archive_path, 'w')
mbox_archive.write(response.content)
diff --git a/py-fake-service/app/search/search_query.py b/py-fake-service/app/search/search_query.py
index 765d1008..ec9b054f 100644
--- a/py-fake-service/app/search/search_query.py
+++ b/py-fake-service/app/search/search_query.py
@@ -49,17 +49,20 @@ class SearchQuery:
self.compiled = compiled
def test(self, mail):
+ if 'all' in self.compiled.get('tags'):
+ return True
+
if set(self.compiled.get('not_tags')).intersection(set(mail.tags)):
return False
- if set(self.compiled.get('tags')).intersection(set(mail.tags)) or 'all' in self.compiled.get('tags'):
+ if set(self.compiled.get('tags')).intersection(set(mail.tags)):
return True
if self.compiled.get('general'):
search_terms = re.compile(
self.compiled['general'],
flags=re.IGNORECASE)
- if search_terms.search(mail.body) or search_terms.search(mail.subject):
+ if search_terms.search(mail.subject+' '+mail.body):
return True
if not [v for v in self.compiled.values() if v]: