# HG changeset patch # User Sandro Knauß # Date 1290045508 -3600 # Node ID 35228d665310e109c5f1f0d59ccd9fe1f052f71e # Parent 04dfd43dfecc3833d71bd4218b93bfc4627f8391 vergleichbarer Content diff -r 04dfd43dfecc -r 35228d665310 iro/anbieter/content.py --- a/iro/anbieter/content.py Thu Nov 18 01:25:28 2010 +0100 +++ b/iro/anbieter/content.py Thu Nov 18 02:58:28 2010 +0100 @@ -24,6 +24,12 @@ def getContent(self): return self.content + def __eq__(self,other): + return self.content == other.content + + def __ne__(self,other): + return not self.__eq__(other) + class SMS(content): def __init__(self, cont): content.__init__(self,cont) @@ -31,6 +37,7 @@ def sendto(self,anbieter,recipients): anbieter.sendSMS(self,recipients) + class FAX(content): def __init__(self,header,cont,attachments): content.__init__(self,cont) @@ -41,9 +48,26 @@ anbieter.sendFAX(self,recipients) def getAttachment(self,i): - print self.attachments return self.attachments[i] + def __eq__(self,other): + if not content.__eq__(self,other): + return False + + if self.header != other.header: + return False + + if len(self.attachments) != len(other.attachments): + return False + + for i in range(len(self.attachments)): + if self.attachments[i] != other.attachments[i]: + return False + + return True + + + class Mail(content): def __init__(self, subject, body, frm): con=MIMEText(body.encode("utf-8"), _charset='utf-8') @@ -60,3 +84,12 @@ def getFrom(self): return self.frm + + def __eq__(self,other): + if self.as_string() != other.as_string(): + return False + + if self.frm != other.frm: + return False + + return True