1.1 --- a/tests/test_send.py Mon Oct 29 22:36:16 2012 +0100
1.2 +++ b/tests/test_send.py Fri Jan 18 00:36:13 2013 +0100
1.3 @@ -5,19 +5,35 @@
1.4 import sys
1.5
1.6 if __name__ == "__main__":
1.7 - signer = sys.argv[1]
1.8 - recipient = sys.argv[2]
1.9 - url = sys.argv[3] + "?action=PostMessage"
1.10 - args = sys.argv[4:]
1.11 + try:
1.12 + signer = sys.argv[1]
1.13 + recipient = sys.argv[2]
1.14 + url = sys.argv[3] + "?action=PostMessage"
1.15 + type = sys.argv[4]
1.16 + action = sys.argv[5]
1.17 + args = sys.argv[6:]
1.18 + except IndexError:
1.19 + args = None
1.20
1.21 if not args:
1.22 - print >>sys.stderr, "Need some updates as arguments to this program."
1.23 + print >>sys.stderr, "Need a signer, recipient, URL, update type, action and some updates as arguments to this program."
1.24 sys.exit(1)
1.25
1.26 message = Message()
1.27 + parts = []
1.28
1.29 for arg in args:
1.30 - message.add_update([MIMEText(arg, "moin")])
1.31 + part = MIMEText(arg, "moin", sys.stdin.encoding)
1.32 + if type == "collection":
1.33 + part["Update-Action"] = action
1.34 + message.add_update(part)
1.35 + else:
1.36 + parts.append(part)
1.37 +
1.38 + if type != "collection":
1.39 + multipart = message.get_update(parts)
1.40 + multipart["Update-Action"] = action
1.41 + message.add_update(multipart)
1.42
1.43 email_message = message.get_payload()
1.44 gpg = GPG()