Skip to content

Commit

Permalink
Updating tests and fixing buglets after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
BjarniRunar committed Jan 3, 2014
1 parent 4419cde commit af9f650
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion mailpile/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ def _metadata(self, msg_info):
'mid': msg_info[MailIndex.MSG_MID],
'id': msg_info[MailIndex.MSG_ID],
'timestamp': msg_ts,
'from_aid': list(self._msg_addresses(msg_info, no_to=True))[0],
'from_aid': (list(self._msg_addresses(msg_info, no_to=True))
or [''])[0],
'to_aids': self._msg_addresses(msg_info, no_from=True),
'tag_tids': self._msg_tags(msg_info),
'thread_mid': msg_info[MailIndex.MSG_CONV_MID],
Expand Down
4 changes: 2 additions & 2 deletions mailpile/plugins/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def command(self, save=True):
s = Action(self.session, "search",
["in:Sent", "to:%s" % (email["email"])]).as_dict()
contact["sent_messages"] += s["result"]["stats"]["total"]
for mid in s["result"]["threads"]:
for mid in s["result"]["thread_ids"]:
msg = s["result"]["data"]["metadata"][mid]
if msg["timestamp"] < contact["last_contact_to"]:
contact["last_contact_to"] = msg["timestamp"]
Expand All @@ -245,7 +245,7 @@ def command(self, save=True):
s = Action(self.session, "search",
["from:%s" % (email["email"])]).as_dict()
contact["received_messages"] += s["result"]["stats"]["total"]
for mid in s["result"]["threads"]:
for mid in s["result"]["thread_ids"]:
msg = s["result"]["data"]["metadata"][mid]
if msg["timestamp"] < contact["last_contact_from"]:
contact["last_contact_from"] = msg["timestamp"]
Expand Down
16 changes: 8 additions & 8 deletions scripts/mailpile-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,22 @@ def say(stuff):

# Make sure we are decoding weird headers correctly
search_bre = mp.search(*FROM_BRE).result
result_bre = search_bre['data']['metadata'][search_bre['threads'][0]]
result_bre = search_bre['data']['metadata'][search_bre['thread_ids'][0]]
view_bre = mp.view('=%s' % result_bre['mid']).result
metadata_bre = view_bre['data']['metadata'][view_bre['threads'][0]]
message_bre = view_bre['data']['message'][view_bre['threads'][0]]
say('Checking encoding: %s' % metadata_bre['from'])
assert('=C3' not in metadata_bre['from']['fn'])
assert('=C3' not in metadata_bre['from']['address'])
metadata_bre = view_bre['data']['metadata'][view_bre['thread_ids'][0]]
message_bre = view_bre['data']['messages'][view_bre['thread_ids'][0]]
from_bre = search_bre['data']['addresses'][metadata_bre['from_aid']]
say('Checking encoding: %s' % from_bre)
assert('=C3' not in from_bre['fn'])
assert('=C3' not in from_bre['address'])
for key, val in message_bre['header_list']:
if key.lower() not in ('from' ,'to', 'cc'):
continue
say('Checking encoding: %s: %s' % (key, val))
assert('utf' not in val)

# Create a message...
new_mid = mp.message_compose().result['threads'][0]
new_mid = mp.message_compose().result['thread_ids'][0]
assert(mp.search('tag:drafts').result['stats']['count'] == 0)
assert(mp.search('tag:blank').result['stats']['count'] == 1)
assert(mp.search('tag:sent').result['stats']['count'] == 0)
Expand Down Expand Up @@ -168,7 +169,6 @@ def say(stuff):
assert('thisisauniquestring' in contents(mailpile_sent))
assert('secret@test.com' not in grepv('X-Args', mailpile_sent))
assert('-i nasty@test.com' in contents(mailpile_sent))
os.remove(mailpile_sent)

say("Tests passed, woot!")
except:
Expand Down

0 comments on commit af9f650

Please sign in to comment.