diff test/test_mailgw.py @ 7064:3359dc1dabb0

Add OAuth authentication to the mailgw script Now IMAPS can be used with OAuth as required by several large cloud providers. Move command line processing of the mailgw script to ``argparse``. Note that the command line options of the mailgw have changed, see upgrading.txt for details.
author Ralf Schlatterbeck <rsc@runtux.com>
date Wed, 23 Nov 2022 10:13:48 +0100
parents bd2c3b2010c3
children 27c2d7295ba2
line wrap: on
line diff
--- a/test/test_mailgw.py	Tue Nov 22 17:10:39 2022 -0500
+++ b/test/test_mailgw.py	Wed Nov 23 10:13:48 2022 +0100
@@ -38,6 +38,7 @@
 
 from roundup.anypy.email_ import message_from_bytes
 from roundup.anypy.strings import b2s, u2s, s2b
+from roundup.scripts.roundup_mailgw import parse_arguments
 
 if 'SENDMAILDEBUG' not in os.environ:
     os.environ['SENDMAILDEBUG'] = 'mail-test.log'
@@ -242,7 +243,7 @@
         ]
         self.db.security.role['anonymous'].permissions = p
 
-    def _create_mailgw(self, message, args=()):
+    def _create_mailgw(self, message, args=[]):
         class MailGW(self.instance.MailGW):
             """call _handle_message as handle_message 
                the real handle_message reopens the database, and destroys
@@ -250,11 +251,12 @@
             """
             def handle_message(self, message):
                 return self._handle_message(message)
-        handler = MailGW(self.instance, args)
+        cmd, parsed_args = parse_arguments (args)
+        handler = MailGW(self.instance, parsed_args)
         handler.db = self.db
         return handler
 
-    def _handle_mail(self, message, args=(), trap_exc=0):
+    def _handle_mail(self, message, args=[], trap_exc=0):
         handler = self._create_mailgw(message, args)
         handler.trapExceptions = trap_exc
         return handler.main(io.BytesIO(s2b(message)))
@@ -444,7 +446,7 @@
 Subject: [issue] Testing...
 
 Hi there!
-''', (('-C', 'issue'), ('-S', 'status=chatting;priority=critical')))
+''', ('-S', 'issue.status=chatting;priority=critical'))
         self.assertEqual(self.db.issue.get(nodeid, 'status'), '3')
         self.assertEqual(self.db.issue.get(nodeid, 'priority'), '1')
 
@@ -458,7 +460,7 @@
 Subject: [issue] Testing...
 
 Hi there!
-''', (('-C', 'issue'), ('-S', 'status=chatting'), ('-S', 'priority=critical')))
+''', ('-S', 'issue.status=chatting', '-S', 'issue.priority=critical'))
         self.assertEqual(self.db.issue.get(nodeid, 'status'), '3')
         self.assertEqual(self.db.issue.get(nodeid, 'priority'), '1')
 
@@ -472,7 +474,7 @@
 Subject: [issue] Testing... [status=chatting;priority=critical]
 
 Hi there!
-''', (('-c', 'issue'),))
+''', ('-c', 'issue'))
         self.assertEqual(self.db.issue.get(nodeid, 'title'), 'Testing...')
         self.assertEqual(self.db.issue.get(nodeid, 'status'), '3')
         self.assertEqual(self.db.issue.get(nodeid, 'priority'), '1')
@@ -5038,4 +5040,4 @@
         l = self.db.msg.get(m, 'tx_Source')
         self.assertEqual(l, 'email-sig-openpgp')
 
-# vim: set filetype=python sts=4 sw=4 et si :
+# vim: set filetype=python sts=4 sw=4 et :

Roundup Issue Tracker: http://roundup-tracker.org/