Live Email checking
- only check for email received while connected to Jabber (not before) darcs-hash:20060131233309-86b55-56666f0af136645b96407db8e3c877b1c2432577.gz
This commit is contained in:
@@ -214,6 +214,10 @@ class MailComponent(Component):
|
|||||||
label = lang_class.account_check_interval, \
|
label = lang_class.account_check_interval, \
|
||||||
var = "interval", \
|
var = "interval", \
|
||||||
value = unicode(self.__interval))
|
value = unicode(self.__interval))
|
||||||
|
|
||||||
|
reg_form.add_field(type = "boolean", \
|
||||||
|
label = lang_class.account_live_email_only, \
|
||||||
|
var = "live_email_only")
|
||||||
|
|
||||||
return reg_form
|
return reg_form
|
||||||
|
|
||||||
@@ -349,6 +353,12 @@ class MailComponent(Component):
|
|||||||
label = lang_class.account_check_interval, \
|
label = lang_class.account_check_interval, \
|
||||||
var = "interval", \
|
var = "interval", \
|
||||||
value = str(account.interval))
|
value = str(account.interval))
|
||||||
|
|
||||||
|
reg_form_init.add_field(type = "boolean", \
|
||||||
|
label = lang_class.account_live_email_only, \
|
||||||
|
var = "live_email_only", \
|
||||||
|
value = str(account.live_email_only).lower())
|
||||||
|
|
||||||
return reg_form_init
|
return reg_form_init
|
||||||
|
|
||||||
""" Looping method """
|
""" Looping method """
|
||||||
@@ -619,10 +629,13 @@ class MailComponent(Component):
|
|||||||
else:
|
else:
|
||||||
interval = None
|
interval = None
|
||||||
|
|
||||||
self.__logger.debug(u"New Account: %s, %s, %s, %s, %s, %s, %s, %s %i %i %i %i %i %i %i" \
|
live_email_only = x.fields.has_key("live_email_only") \
|
||||||
|
and (x.fields["live_email_only"].value == "1")
|
||||||
|
|
||||||
|
self.__logger.debug(u"New Account: %s, %s, %s, %s, %s, %s, %s, %s %i %i %i %i %i %i %i %s" \
|
||||||
% (name, login, password, str(store_password), host, str(port), \
|
% (name, login, password, str(store_password), host, str(port), \
|
||||||
mailbox, type, chat_action, online_action, away_action, \
|
mailbox, type, chat_action, online_action, away_action, \
|
||||||
xa_action, dnd_action, offline_action, interval))
|
xa_action, dnd_action, offline_action, interval, str(live_email_only)))
|
||||||
|
|
||||||
iq = iq.make_result_response()
|
iq = iq.make_result_response()
|
||||||
self.stream.send(iq)
|
self.stream.send(iq)
|
||||||
@@ -667,6 +680,7 @@ class MailComponent(Component):
|
|||||||
account.dnd_action = dnd_action
|
account.dnd_action = dnd_action
|
||||||
account.offline_action = offline_action
|
account.offline_action = offline_action
|
||||||
account.interval = interval
|
account.interval = interval
|
||||||
|
account.live_email_only = live_email_only
|
||||||
|
|
||||||
if port:
|
if port:
|
||||||
account.port = port
|
account.port = port
|
||||||
@@ -821,12 +835,13 @@ class MailComponent(Component):
|
|||||||
def check_mail(self, jid, name):
|
def check_mail(self, jid, name):
|
||||||
self.__logger.debug("CHECK_MAIL " + unicode(jid) + " " + name)
|
self.__logger.debug("CHECK_MAIL " + unicode(jid) + " " + name)
|
||||||
account = self.__storage[(jid, name)]
|
account = self.__storage[(jid, name)]
|
||||||
if account.password is None:
|
|
||||||
self.__ask_password(name, jid, account.default_lang_class, account)
|
|
||||||
return
|
|
||||||
action = account.action
|
action = account.action
|
||||||
|
|
||||||
if action != mailconnection.DO_NOTHING:
|
if action != mailconnection.DO_NOTHING:
|
||||||
try:
|
try:
|
||||||
|
if account.password is None:
|
||||||
|
self.__ask_password(name, jid, account.default_lang_class, account)
|
||||||
|
return
|
||||||
self.__logger.debug("Checking " + name)
|
self.__logger.debug("Checking " + name)
|
||||||
self.__logger.debug("\t" + account.login \
|
self.__logger.debug("\t" + account.login \
|
||||||
+ "@" + account.host)
|
+ "@" + account.host)
|
||||||
@@ -884,6 +899,33 @@ class MailComponent(Component):
|
|||||||
self.__logger.debug("CHECK_ALL_MAIL")
|
self.__logger.debug("CHECK_ALL_MAIL")
|
||||||
for jid, name in self.__storage.keys():
|
for jid, name in self.__storage.keys():
|
||||||
account = self.__storage[(jid, name)]
|
account = self.__storage[(jid, name)]
|
||||||
|
if account.first_check and account.live_email_only:
|
||||||
|
account.first_check = False
|
||||||
|
print "HERE"
|
||||||
|
if account.password is None:
|
||||||
|
self.__ask_password(name, jid, account.default_lang_class, account)
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
account.connect()
|
||||||
|
mail_list = account.get_mail_list()
|
||||||
|
if not mail_list or mail_list[0] == '':
|
||||||
|
account.lastmail = 0
|
||||||
|
else:
|
||||||
|
account.lastmail = len(mail_list)
|
||||||
|
account.disconnect()
|
||||||
|
account.in_error = False
|
||||||
|
except Exception,e:
|
||||||
|
if account.in_error == False:
|
||||||
|
account.in_error = True
|
||||||
|
msg = Message(from_jid = name + "@" + unicode(self.jid), \
|
||||||
|
to_jid = jid, \
|
||||||
|
stanza_type = "error", \
|
||||||
|
subject = account.default_lang_class.check_error_subject, \
|
||||||
|
body = account.default_lang_class.check_error_body \
|
||||||
|
% (e))
|
||||||
|
self.stream.send(msg)
|
||||||
|
self.__logger.debug("Error while checking mail : %s" \
|
||||||
|
% (e))
|
||||||
account.lastcheck += 1
|
account.lastcheck += 1
|
||||||
if account.lastcheck == account.interval:
|
if account.lastcheck == account.interval:
|
||||||
account.lastcheck = 0
|
account.lastcheck = 0
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class Lang:
|
|||||||
account_dnd_action = u"Action when state is 'Do not Disturb'"
|
account_dnd_action = u"Action when state is 'Do not Disturb'"
|
||||||
account_offline_action = u"Action when state is 'Offline'"
|
account_offline_action = u"Action when state is 'Offline'"
|
||||||
account_check_interval = u"Mail check interval (in minutes)"
|
account_check_interval = u"Mail check interval (in minutes)"
|
||||||
|
account_live_email_only = u"Reports only emails received while connected to Jabber"
|
||||||
action_nothing = u"Do nothing"
|
action_nothing = u"Do nothing"
|
||||||
action_retrieve = u"Retrieve mail"
|
action_retrieve = u"Retrieve mail"
|
||||||
action_digest = u"Send mail digest"
|
action_digest = u"Send mail digest"
|
||||||
@@ -78,6 +79,8 @@ class Lang:
|
|||||||
account_dnd_action = u"Action lorsque l'état est 'Do not Disturb'"
|
account_dnd_action = u"Action lorsque l'état est 'Do not Disturb'"
|
||||||
account_offline_action = u"Action lorsque l'état est 'Offline'"
|
account_offline_action = u"Action lorsque l'état est 'Offline'"
|
||||||
account_check_interval = u"Interval de vérification de nouveaux emails (en minutes)"
|
account_check_interval = u"Interval de vérification de nouveaux emails (en minutes)"
|
||||||
|
account_live_email_only = u"Vérifier les nouveaux emails seulement " \
|
||||||
|
"lorsqu'une session Jabber est ouverte"
|
||||||
action_nothing = u"Ne rien faire"
|
action_nothing = u"Ne rien faire"
|
||||||
action_retrieve = u"Récupérer l'email"
|
action_retrieve = u"Récupérer l'email"
|
||||||
action_digest = u"Envoyer un résumé"
|
action_digest = u"Envoyer un résumé"
|
||||||
@@ -98,4 +101,3 @@ class Lang:
|
|||||||
check_error_subject = u"Erreur lors de la vérification des emails."
|
check_error_subject = u"Erreur lors de la vérification des emails."
|
||||||
check_error_body = u"Une erreur est survenue lors de la vérification " \
|
check_error_body = u"Une erreur est survenue lors de la vérification " \
|
||||||
"des emails :\n\t%s"
|
"des emails :\n\t%s"
|
||||||
|
|
||||||
|
|||||||
@@ -165,11 +165,13 @@ class MailConnection(object):
|
|||||||
self.default_lang_class = Lang.en
|
self.default_lang_class = Lang.en
|
||||||
self.waiting_password_reply = False
|
self.waiting_password_reply = False
|
||||||
self.in_error = False
|
self.in_error = False
|
||||||
|
self.live_email_only = False
|
||||||
|
self.first_check = True
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return self.get_type() == other.get_type() \
|
return self.get_type() == other.get_type() \
|
||||||
and self.login == other.login \
|
and self.login == other.login \
|
||||||
and self.password == other.password \
|
and (not self.store_password or self.password == other.password) \
|
||||||
and self.store_password == other.store_password \
|
and self.store_password == other.store_password \
|
||||||
and self.host == other.host \
|
and self.host == other.host \
|
||||||
and self.port == other.port \
|
and self.port == other.port \
|
||||||
@@ -180,14 +182,15 @@ class MailConnection(object):
|
|||||||
and self.xa_action == other.xa_action \
|
and self.xa_action == other.xa_action \
|
||||||
and self.dnd_action == other.dnd_action \
|
and self.dnd_action == other.dnd_action \
|
||||||
and self.offline_action == other.offline_action \
|
and self.offline_action == other.offline_action \
|
||||||
and self.interval == other.interval
|
and self.interval == other.interval \
|
||||||
|
and self.live_email_only == other.live_email_only
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.get_type() + "#" + self.login + "#" + \
|
return self.get_type() + "#" + self.login + "#" + \
|
||||||
(self.store_password and self.password or "/\\") + "#" \
|
(self.store_password and self.password or "/\\") + "#" \
|
||||||
+ self.host + "#" + str(self.port) + "#" + str(self.chat_action) + "#" \
|
+ self.host + "#" + str(self.port) + "#" + str(self.chat_action) + "#" \
|
||||||
+ str(self.online_action) + "#" + str(self.away_action) + "#" + \
|
+ str(self.online_action) + "#" + str(self.away_action) + "#" + \
|
||||||
str(self.xa_action) + "#" + str(self.dnd_action) + "#" + str(self.offline_action) + "#" + str(self.interval)
|
str(self.xa_action) + "#" + str(self.dnd_action) + "#" + str(self.offline_action) + "#" + str(self.interval) + "#" + str(self.live_email_only)
|
||||||
|
|
||||||
def get_decoded_part(self, part):
|
def get_decoded_part(self, part):
|
||||||
content_charset = part.get_content_charset()
|
content_charset = part.get_content_charset()
|
||||||
|
|||||||
@@ -75,8 +75,9 @@ def str_to_mail_connection(connection_string):
|
|||||||
dnd_action = None
|
dnd_action = None
|
||||||
offline_action = None
|
offline_action = None
|
||||||
interval = None
|
interval = None
|
||||||
|
live_email_only = False
|
||||||
if type[0:4] == "imap":
|
if type[0:4] == "imap":
|
||||||
if len(arg_list) == 8:
|
if len(arg_list) == 9:
|
||||||
chat_action = int(arg_list.pop())
|
chat_action = int(arg_list.pop())
|
||||||
online_action = int(arg_list.pop())
|
online_action = int(arg_list.pop())
|
||||||
away_action = int(arg_list.pop())
|
away_action = int(arg_list.pop())
|
||||||
@@ -84,6 +85,7 @@ def str_to_mail_connection(connection_string):
|
|||||||
dnd_action = int(arg_list.pop())
|
dnd_action = int(arg_list.pop())
|
||||||
offline_action = int(arg_list.pop())
|
offline_action = int(arg_list.pop())
|
||||||
interval = int(arg_list.pop())
|
interval = int(arg_list.pop())
|
||||||
|
live_email_only = (arg_list.pop().lower() == "true")
|
||||||
else:
|
else:
|
||||||
retrieve = bool(arg_list.pop() == "True")
|
retrieve = bool(arg_list.pop() == "True")
|
||||||
if retrieve:
|
if retrieve:
|
||||||
@@ -99,7 +101,7 @@ def str_to_mail_connection(connection_string):
|
|||||||
port = port, \
|
port = port, \
|
||||||
mailbox = mailbox)
|
mailbox = mailbox)
|
||||||
else:
|
else:
|
||||||
if len(arg_list) == 7:
|
if len(arg_list) == 8:
|
||||||
chat_action = int(arg_list.pop())
|
chat_action = int(arg_list.pop())
|
||||||
online_action = int(arg_list.pop())
|
online_action = int(arg_list.pop())
|
||||||
away_action = int(arg_list.pop())
|
away_action = int(arg_list.pop())
|
||||||
@@ -107,6 +109,7 @@ def str_to_mail_connection(connection_string):
|
|||||||
dnd_action = int(arg_list.pop())
|
dnd_action = int(arg_list.pop())
|
||||||
offline_action = int(arg_list.pop())
|
offline_action = int(arg_list.pop())
|
||||||
interval = int(arg_list.pop())
|
interval = int(arg_list.pop())
|
||||||
|
live_email_only = (arg_list.pop().lower() == "true")
|
||||||
else:
|
else:
|
||||||
retrieve = bool(arg_list.pop() == "True")
|
retrieve = bool(arg_list.pop() == "True")
|
||||||
if retrieve:
|
if retrieve:
|
||||||
@@ -130,6 +133,7 @@ def str_to_mail_connection(connection_string):
|
|||||||
result.offline_action = offline_action
|
result.offline_action = offline_action
|
||||||
if interval is not None:
|
if interval is not None:
|
||||||
result.interval = interval
|
result.interval = interval
|
||||||
|
result.live_email_only = live_email_only
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ class SQLiteStorage(Storage):
|
|||||||
dnd_action INTEGER,
|
dnd_action INTEGER,
|
||||||
offline_action INTEGER,
|
offline_action INTEGER,
|
||||||
interval INTEGER,
|
interval INTEGER,
|
||||||
|
live_email_only BOOLEAN,
|
||||||
mailbox STRING,
|
mailbox STRING,
|
||||||
PRIMARY KEY(jid, name)
|
PRIMARY KEY(jid, name)
|
||||||
)
|
)
|
||||||
@@ -211,14 +212,33 @@ class SQLiteStorage(Storage):
|
|||||||
cursor.execute("""select * from account""")
|
cursor.execute("""select * from account""")
|
||||||
result = {}
|
result = {}
|
||||||
for row in cursor.fetchall():
|
for row in cursor.fetchall():
|
||||||
# print "Creating new " + row[self.nb_pk_fields] + " connection."
|
# print "Creating new " + row[self.nb_pk_fields] + " connection."
|
||||||
account = result["#".join(row[0:self.nb_pk_fields])] = mailconnection_factory.get_new_mail_connection(row[self.nb_pk_fields])
|
account_type = row[self.nb_pk_fields]
|
||||||
for field_index in range(self.nb_pk_fields + 1, len(row)):
|
account = result["#".join(row[0:self.nb_pk_fields])] = mailconnection_factory.get_new_mail_connection(account_type)
|
||||||
|
account.login = row[self.nb_pk_fields + 1]
|
||||||
|
account.password = row[self.nb_pk_fields + 2]
|
||||||
|
if account.password is None:
|
||||||
|
account.store_password = False
|
||||||
|
else:
|
||||||
|
account.store_password = True
|
||||||
|
account.host = row[self.nb_pk_fields + 3]
|
||||||
|
account.port = int(row[self.nb_pk_fields + 4])
|
||||||
|
account.chat_action = int(row[self.nb_pk_fields + 5])
|
||||||
|
account.online_action = int(row[self.nb_pk_fields + 6])
|
||||||
|
account.away_action = int(row[self.nb_pk_fields + 7])
|
||||||
|
account.xa_action = int(row[self.nb_pk_fields + 8])
|
||||||
|
account.dnd_action = int(row[self.nb_pk_fields + 9])
|
||||||
|
account.offline_action = int(row[self.nb_pk_fields + 10])
|
||||||
|
account.interval = int(row[self.nb_pk_fields + 11])
|
||||||
|
account.live_email_only = (row[self.nb_pk_fields + 12] == 1)
|
||||||
|
if account_type[0:4] == "imap":
|
||||||
|
account.mailbox = row[self.nb_pk_fields + 13]
|
||||||
|
# for field_index in range(self.nb_pk_fields + 1, len(row)):
|
||||||
# print "\tSetting " + str(cursor.description[field_index][0]) + \
|
# print "\tSetting " + str(cursor.description[field_index][0]) + \
|
||||||
# " to " + str(row[field_index])
|
# " to " + str(row[field_index])
|
||||||
setattr(account,
|
# setattr(account,
|
||||||
cursor.description[field_index][0],
|
# cursor.description[field_index][0],
|
||||||
row[field_index])
|
# row[field_index])
|
||||||
cursor.close()
|
cursor.close()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -226,17 +246,20 @@ class SQLiteStorage(Storage):
|
|||||||
Storage.__setitem__(self, pk_tuple, obj)
|
Storage.__setitem__(self, pk_tuple, obj)
|
||||||
cursor = self.__connection.cursor()
|
cursor = self.__connection.cursor()
|
||||||
mailbox = None
|
mailbox = None
|
||||||
|
password = None
|
||||||
if obj.type[0:4] == "imap":
|
if obj.type[0:4] == "imap":
|
||||||
mailbox = obj.mailbox
|
mailbox = obj.mailbox
|
||||||
|
if obj.store_password == True:
|
||||||
|
password = obj.password
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
insert or replace into account values
|
insert or replace into account values
|
||||||
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
""",
|
""",
|
||||||
(pk_tuple[0],
|
(pk_tuple[0],
|
||||||
pk_tuple[1],
|
pk_tuple[1],
|
||||||
obj.type,
|
obj.type,
|
||||||
obj.login,
|
obj.login,
|
||||||
obj.password,
|
password,
|
||||||
obj.host,
|
obj.host,
|
||||||
obj.port,
|
obj.port,
|
||||||
obj.chat_action,
|
obj.chat_action,
|
||||||
@@ -246,6 +269,7 @@ class SQLiteStorage(Storage):
|
|||||||
obj.dnd_action,
|
obj.dnd_action,
|
||||||
obj.offline_action,
|
obj.offline_action,
|
||||||
obj.interval,
|
obj.interval,
|
||||||
|
obj.live_email_only,
|
||||||
mailbox))
|
mailbox))
|
||||||
self.__connection.commit()
|
self.__connection.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ if __name__ == '__main__':
|
|||||||
# test_support.run_suite(mc_factory_suite)
|
# test_support.run_suite(mc_factory_suite)
|
||||||
# test_support.run_suite(component_suite)
|
# test_support.run_suite(component_suite)
|
||||||
# test_support.run_suite(component2_suite)
|
# test_support.run_suite(component2_suite)
|
||||||
# test_support.run_suite(storage_suite)
|
#test_support.run_suite(storage_suite)
|
||||||
# test_support.run_suite(sqlitestorage_suite)
|
#test_support.run_suite(sqlitestorage_suite)
|
||||||
# test_support.run_suite(dbmstorage_suite)
|
#test_support.run_suite(dbmstorage_suite)
|
||||||
test_support.run_suite(jmc_suite)
|
test_support.run_suite(jmc_suite)
|
||||||
|
|
||||||
# coverage.stop()
|
# coverage.stop()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<URL>http://people.happycoders.org/dax/jabber/jmc/</URL>
|
<URL>http://people.happycoders.org/dax/jabber/jmc/</URL>
|
||||||
</vCard>
|
</vCard>
|
||||||
</jabber>
|
</jabber>
|
||||||
<storage>DBM</storage>
|
<storage>SQLite</storage>
|
||||||
<spooldir>.</spooldir>
|
<spooldir>.</spooldir>
|
||||||
<check_interval>5</check_interval> <!-- in minutes -->
|
<check_interval>5</check_interval> <!-- in minutes -->
|
||||||
</config>
|
</config>
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class MailConnectionFactory_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(mc.dnd_action, mailconnection.RETRIEVE)
|
self.assertEquals(mc.dnd_action, mailconnection.RETRIEVE)
|
||||||
self.assertEquals(mc.offline_action, mailconnection.DO_NOTHING)
|
self.assertEquals(mc.offline_action, mailconnection.DO_NOTHING)
|
||||||
self.assertEquals(mc.interval, 5)
|
self.assertEquals(mc.interval, 5)
|
||||||
|
self.assertEquals(mc.live_email_only, False)
|
||||||
|
|
||||||
def test_str_to_mail_connection_pop3_v01_v02(self):
|
def test_str_to_mail_connection_pop3_v01_v02(self):
|
||||||
mc = str_to_mail_connection("pop3#login#passwd#host#110#False")
|
mc = str_to_mail_connection("pop3#login#passwd#host#110#False")
|
||||||
@@ -74,9 +75,10 @@ class MailConnectionFactory_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
||||||
self.assertEquals(mc.offline_action, mailconnection.DO_NOTHING)
|
self.assertEquals(mc.offline_action, mailconnection.DO_NOTHING)
|
||||||
self.assertEquals(mc.interval, 5)
|
self.assertEquals(mc.interval, 5)
|
||||||
|
self.assertEquals(mc.live_email_only, False)
|
||||||
|
|
||||||
def test_str_to_mail_connection_imap(self):
|
def test_str_to_mail_connection_imap(self):
|
||||||
mc = str_to_mail_connection("imap#login#passwd#host#193#0#0#0#1#1#2#4#INBOX")
|
mc = str_to_mail_connection("imap#login#passwd#host#193#0#0#0#1#1#2#4#True#INBOX")
|
||||||
self.assertEquals(mc.get_type(), "imap")
|
self.assertEquals(mc.get_type(), "imap")
|
||||||
self.assertEquals(mc.login, "login")
|
self.assertEquals(mc.login, "login")
|
||||||
self.assertEquals(mc.password, "passwd")
|
self.assertEquals(mc.password, "passwd")
|
||||||
@@ -90,9 +92,10 @@ class MailConnectionFactory_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
||||||
self.assertEquals(mc.offline_action, mailconnection.RETRIEVE)
|
self.assertEquals(mc.offline_action, mailconnection.RETRIEVE)
|
||||||
self.assertEquals(mc.interval, 4)
|
self.assertEquals(mc.interval, 4)
|
||||||
|
self.assertEquals(mc.live_email_only, True)
|
||||||
|
|
||||||
def test_str_to_mail_connection_no_password(self):
|
def test_str_to_mail_connection_no_password(self):
|
||||||
mc = str_to_mail_connection("imap#login#/\\#host#193#0#0#0#1#1#2#4#INBOX")
|
mc = str_to_mail_connection("imap#login#/\\#host#193#0#0#0#1#1#2#4#False#INBOX")
|
||||||
self.assertEquals(mc.get_type(), "imap")
|
self.assertEquals(mc.get_type(), "imap")
|
||||||
self.assertEquals(mc.login, "login")
|
self.assertEquals(mc.login, "login")
|
||||||
self.assertEquals(mc.password, None)
|
self.assertEquals(mc.password, None)
|
||||||
@@ -107,9 +110,10 @@ class MailConnectionFactory_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
||||||
self.assertEquals(mc.offline_action, mailconnection.RETRIEVE)
|
self.assertEquals(mc.offline_action, mailconnection.RETRIEVE)
|
||||||
self.assertEquals(mc.interval, 4)
|
self.assertEquals(mc.interval, 4)
|
||||||
|
self.assertEquals(mc.live_email_only, False)
|
||||||
|
|
||||||
def test_str_to_mail_connection_imaps(self):
|
def test_str_to_mail_connection_imaps(self):
|
||||||
mc = str_to_mail_connection("imaps#login#passwd#host#993#0#0#0#1#1#2#4#INBOX.SubDir")
|
mc = str_to_mail_connection("imaps#login#passwd#host#993#0#0#0#1#1#2#4#True#INBOX.SubDir")
|
||||||
self.assertEquals(mc.get_type(), "imaps")
|
self.assertEquals(mc.get_type(), "imaps")
|
||||||
self.assertEquals(mc.login, "login")
|
self.assertEquals(mc.login, "login")
|
||||||
self.assertEquals(mc.password, "passwd")
|
self.assertEquals(mc.password, "passwd")
|
||||||
@@ -123,9 +127,10 @@ class MailConnectionFactory_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
||||||
self.assertEquals(mc.offline_action, mailconnection.RETRIEVE)
|
self.assertEquals(mc.offline_action, mailconnection.RETRIEVE)
|
||||||
self.assertEquals(mc.interval, 4)
|
self.assertEquals(mc.interval, 4)
|
||||||
|
self.assertEquals(mc.live_email_only, True)
|
||||||
|
|
||||||
def test_str_to_mail_connection_pop3(self):
|
def test_str_to_mail_connection_pop3(self):
|
||||||
mc = str_to_mail_connection("pop3#login#passwd#host#110#0#0#0#1#1#2#4")
|
mc = str_to_mail_connection("pop3#login#passwd#host#110#0#0#0#1#1#2#4#False")
|
||||||
self.assertEquals(mc.get_type(), "pop3")
|
self.assertEquals(mc.get_type(), "pop3")
|
||||||
self.assertEquals(mc.login, "login")
|
self.assertEquals(mc.login, "login")
|
||||||
self.assertEquals(mc.password, "passwd")
|
self.assertEquals(mc.password, "passwd")
|
||||||
@@ -138,9 +143,10 @@ class MailConnectionFactory_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
||||||
self.assertEquals(mc.offline_action, mailconnection.RETRIEVE)
|
self.assertEquals(mc.offline_action, mailconnection.RETRIEVE)
|
||||||
self.assertEquals(mc.interval, 4)
|
self.assertEquals(mc.interval, 4)
|
||||||
|
self.assertEquals(mc.live_email_only, False)
|
||||||
|
|
||||||
def test_str_to_mail_connection_pop3s(self):
|
def test_str_to_mail_connection_pop3s(self):
|
||||||
mc = str_to_mail_connection("pop3s#login#passwd#host#995#0#0#0#1#1#2#4")
|
mc = str_to_mail_connection("pop3s#login#passwd#host#995#0#0#0#1#1#2#4#True")
|
||||||
self.assertEquals(mc.get_type(), "pop3s")
|
self.assertEquals(mc.get_type(), "pop3s")
|
||||||
self.assertEquals(mc.login, "login")
|
self.assertEquals(mc.login, "login")
|
||||||
self.assertEquals(mc.password, "passwd")
|
self.assertEquals(mc.password, "passwd")
|
||||||
@@ -153,4 +159,5 @@ class MailConnectionFactory_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
self.assertEquals(mc.dnd_action, mailconnection.DIGEST)
|
||||||
self.assertEquals(mc.offline_action, mailconnection.RETRIEVE)
|
self.assertEquals(mc.offline_action, mailconnection.RETRIEVE)
|
||||||
self.assertEquals(mc.interval, 4)
|
self.assertEquals(mc.interval, 4)
|
||||||
|
self.assertEquals(mc.live_email_only, True)
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ class DBMStorage_TestCase(unittest.TestCase):
|
|||||||
self._account2.dnd_action = mailconnection.DO_NOTHING
|
self._account2.dnd_action = mailconnection.DO_NOTHING
|
||||||
self._account2.offline_action = mailconnection.DO_NOTHING
|
self._account2.offline_action = mailconnection.DO_NOTHING
|
||||||
self._account2.interval = 4
|
self._account2.interval = 4
|
||||||
|
self._account2.store_password = False
|
||||||
|
self._account2.live_email_only = True
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
db_file = self._storage.file
|
db_file = self._storage.file
|
||||||
@@ -190,6 +192,8 @@ class SQLiteStorage_TestCase(DBMStorage_TestCase):
|
|||||||
self._account2.dnd_action = mailconnection.DO_NOTHING
|
self._account2.dnd_action = mailconnection.DO_NOTHING
|
||||||
self._account2.offline_action = mailconnection.DO_NOTHING
|
self._account2.offline_action = mailconnection.DO_NOTHING
|
||||||
self._account2.interval = 4
|
self._account2.interval = 4
|
||||||
|
self._account2.store_password = False
|
||||||
|
self._account2.live_email_only = True
|
||||||
|
|
||||||
# def tearDown(self):
|
# def tearDown(self):
|
||||||
# os.remove(self._storage.file)
|
# os.remove(self._storage.file)
|
||||||
@@ -199,6 +203,7 @@ class SQLiteStorage_TestCase(DBMStorage_TestCase):
|
|||||||
def test_set_sync_get(self):
|
def test_set_sync_get(self):
|
||||||
self._storage[("test@localhost", "account1")] = self._account1
|
self._storage[("test@localhost", "account1")] = self._account1
|
||||||
self._storage[("test@localhost", "account2")] = self._account2
|
self._storage[("test@localhost", "account2")] = self._account2
|
||||||
|
self._account2.password = None
|
||||||
loaded_storage = SQLiteStorage(nb_pk_fields = 2, spool_dir = "./spool/test")
|
loaded_storage = SQLiteStorage(nb_pk_fields = 2, spool_dir = "./spool/test")
|
||||||
self.assertEquals(loaded_storage[("test@localhost", "account1")],
|
self.assertEquals(loaded_storage[("test@localhost", "account1")],
|
||||||
self._account1)
|
self._account1)
|
||||||
|
|||||||
Reference in New Issue
Block a user