[Asterisk-code-review] tests/apps/voicemail: Fix some PEP8 warnings. (testsuite[master])

Richard Mudgett asteriskteam at digium.com
Fri Jul 21 16:17:49 CDT 2017


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/6063


Change subject: tests/apps/voicemail: Fix some PEP8 warnings.
......................................................................

tests/apps/voicemail: Fix some PEP8 warnings.

Change-Id: I74e198aeec42bca908141dead9c0fe23d6f63659
---
M lib/python/asterisk/voicemail.py
M tests/apps/voicemail/authenticate_extensions/run-test
M tests/apps/voicemail/authenticate_invalid_mailbox/run-test
M tests/apps/voicemail/authenticate_invalid_password/run-test
M tests/apps/voicemail/authenticate_nominal/run-test
M tests/apps/voicemail/check_voicemail_callback/run-test
M tests/apps/voicemail/check_voicemail_envelope/run-test
M tests/apps/voicemail/play_message/run-test
8 files changed, 203 insertions(+), 140 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/63/6063/1

diff --git a/lib/python/asterisk/voicemail.py b/lib/python/asterisk/voicemail.py
index 8ea9915..b2d2d96 100644
--- a/lib/python/asterisk/voicemail.py
+++ b/lib/python/asterisk/voicemail.py
@@ -361,27 +361,32 @@
             if not create_all_folders:
                 return True
 
-            inbox_path = ("%(mp)s/%(f)s" % {'mp': mailbox_path,
+            inbox_path = ("%(mp)s/%(f)s" % {
+                'mp': mailbox_path,
                 'f': VoiceMailMailboxManagement.inbox_folder_name})
             if not os.path.isdir(inbox_path):
                 os.makedirs(inbox_path)
 
-            temp_path = ("%(mp)s/%(f)s" % {'mp': mailbox_path,
+            temp_path = ("%(mp)s/%(f)s" % {
+                'mp': mailbox_path,
                 'f': VoiceMailMailboxManagement.temp_folder_name})
             if not os.path.isdir(temp_path):
                 os.makedirs(temp_path)
 
-            old_path = ("%(mp)s/%(f)s" % {'mp': mailbox_path,
+            old_path = ("%(mp)s/%(f)s" % {
+                'mp': mailbox_path,
                 'f': VoiceMailMailboxManagement.old_folder_name})
             if not os.path.isdir(old_path):
                 os.makedirs(old_path)
 
-            urgent_path = ("%(mp)s/%(f)s" % {'mp': mailbox_path,
+            urgent_path = ("%(mp)s/%(f)s" % {
+                'mp': mailbox_path,
                 'f': VoiceMailMailboxManagement.urgent_folder_name})
             if not os.path.isdir(urgent_path):
                 os.makedirs(urgent_path)
 
-            greetings_path = ("%(mp)s/%(f)s" % {'mp': mailbox_path,
+            greetings_path = ("%(mp)s/%(f)s" % {
+                'mp': mailbox_path,
                 'f': VoiceMailMailboxManagement.greetings_folder_name})
             if not os.path.isdir(greetings_path):
                 os.makedirs(greetings_path)
@@ -419,8 +424,9 @@
         msg_name = 'msg%04d' % (msgnum)
         msg_env_name = msg_name + ".txt"
         msg_env_path = (self.__ast.base +
-            "%(vd)s/%(c)s/%(m)s/%(f)s/%(n)s" % {'vd': self.voicemail_directory,
-            'c': context, 'm': mailbox, 'f': folder, 'n': msg_env_name})
+                        "%(vd)s/%(c)s/%(m)s/%(f)s/%(n)s" % {
+                            'vd': self.voicemail_directory,
+                            'c': context, 'm': mailbox, 'f': folder, 'n': msg_env_name})
 
         random.seed()
         msg_id = (str(int(time.time())) + "-" +
@@ -452,15 +458,15 @@
         for snd_format in formats:
             msg_format_name = msg_name + '.' + snd_format
             msg_format_path = (self.__ast.base +
-                "%(vd)s/%(c)s/%(m)s/%(f)s/%(n)s" % {
-                    'vd': self.voicemail_directory,
-                    'c': context,
-                    'm': mailbox,
-                    'f': folder,
-                    'n': msg_format_name})
+                               "%(vd)s/%(c)s/%(m)s/%(f)s/%(n)s" % {
+                                   'vd': self.voicemail_directory,
+                                   'c': context,
+                                   'm': mailbox,
+                                   'f': folder,
+                                   'n': msg_format_name})
             audio_file = os.path.join(os.getcwd(),
                                       "%s/sounds/talking.ulaw" %
-                                        (self.test_parent_dir))
+                                      (self.test_parent_dir))
             shutil.copy(audio_file, msg_format_path)
 
         if folder not in self.created_voicemails.keys():
@@ -552,8 +558,8 @@
         return ret_val
 
     def check_voicemail_property(self, context, mailbox, msgnum,
-                        property_name, property_value,
-                        folder=inbox_folder_name):
+                                 property_name, property_value,
+                                 folder=inbox_folder_name):
         """Check if a voicemail has the property specified
 
         Keyword Arguments:
@@ -707,15 +713,15 @@
             return False
 
         self._remove_items_from_folder(mailbox_path,
-                VoiceMailMailboxManagement.inbox_folder_name)
+                                       VoiceMailMailboxManagement.inbox_folder_name)
         self._remove_items_from_folder(mailbox_path,
-                VoiceMailMailboxManagement.temp_folder_name)
+                                       VoiceMailMailboxManagement.temp_folder_name)
         self._remove_items_from_folder(mailbox_path,
-                VoiceMailMailboxManagement.old_folder_name)
+                                       VoiceMailMailboxManagement.old_folder_name)
         self._remove_items_from_folder(mailbox_path,
-                VoiceMailMailboxManagement.urgent_folder_name)
+                                       VoiceMailMailboxManagement.urgent_folder_name)
         self._remove_items_from_folder(mailbox_path,
-                VoiceMailMailboxManagement.greetings_folder_name)
+                                       VoiceMailMailboxManagement.greetings_folder_name)
 
         if (remove_folders):
             os.rmdir(os.path.join(self.__ast.base, "%(mp)s/%(f)s" % {
diff --git a/tests/apps/voicemail/authenticate_extensions/run-test b/tests/apps/voicemail/authenticate_extensions/run-test
index a0773a1..7f02556 100755
--- a/tests/apps/voicemail/authenticate_extensions/run-test
+++ b/tests/apps/voicemail/authenticate_extensions/run-test
@@ -21,10 +21,11 @@
 
 logger = logging.getLogger(__name__)
 
-"""
-TestState that attempts a login with a mailbox / incorrect password
-"""
+
 class LoginWithMailbox(VoiceMailState):
+    """
+    TestState that attempts a login with a mailbox / incorrect password
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -36,7 +37,10 @@
             if message == 'vm-login':
                 self.voice_mail_test.send_dtmf("1234")
             elif message == 'vm-password':
-                """ Instead of sending a password, ask to be transferred to the attendant extension """
+                """
+                Instead of sending a password, ask to be transferred to the
+                attendant extension
+                """
                 self.voice_mail_test.send_dtmf("*")
                 self.voice_mail_test.reset_timeout()
             elif message == 'vm-incorrect-mailbox':
@@ -55,10 +59,11 @@
     def get_state_name(self):
         return "LOGIN WITH MAILBOX"
 
-"""
-TestState that attempts a login with an incorrect password only
-"""
+
 class LoginWithoutMailbox(VoiceMailState):
+    """
+    TestState that attempts a login with an incorrect password only
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -91,6 +96,7 @@
     def get_state_name(self):
         return "LOGIN WITHOUT MAILBOX"
 
+
 class AuthenticateExtensions(VoiceMailTest):
 
     def __init__(self):
@@ -103,7 +109,10 @@
     def ami_connect(self, ami):
         super(AuthenticateExtensions, self).ami_connect(ami)
 
-        """ Record which AMI instance we've received and attempt to set up the test controller """
+        """
+        Record which AMI instance we've received and attempt to set up
+        the test controller
+        """
         if (ami.id == 0):
             self.ami_receiver = ami
             ami.registerEvent('UserEvent', self.user_event)
@@ -177,4 +186,4 @@
     return 0
 
 if __name__ == "__main__":
-   sys.exit(main() or 0)
+    sys.exit(main() or 0)
diff --git a/tests/apps/voicemail/authenticate_invalid_mailbox/run-test b/tests/apps/voicemail/authenticate_invalid_mailbox/run-test
index 4bb17d3..6b9a6ac 100755
--- a/tests/apps/voicemail/authenticate_invalid_mailbox/run-test
+++ b/tests/apps/voicemail/authenticate_invalid_mailbox/run-test
@@ -21,10 +21,11 @@
 
 logger = logging.getLogger(__name__)
 
-"""
-TestState that is the entry point for the VoiceMail application
-"""
+
 class StartVoiceMailState(VoiceMailState):
+    """
+    TestState that is the entry point for the VoiceMail application
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -57,6 +58,7 @@
     def get_state_name(self):
         return "START"
 
+
 class AuthenticateInvalidMailbox(VoiceMailTest):
 
     def __init__(self):
@@ -67,7 +69,10 @@
     def ami_connect(self, ami):
         super(AuthenticateInvalidMailbox, self).ami_connect(ami)
 
-        """ Record which AMI instance we've received and attempt to set up the test controller """
+        """
+        Record which AMI instance we've received and attempt to set up
+        the test controller
+        """
         if (ami.id == 0):
             self.ami_receiver = ami
             ami.registerEvent('UserEvent', self.user_event)
@@ -96,8 +101,8 @@
             return
 
         """
-        Note that in this test, failure to see any UserEvents is a good thing - if we get to a
-        UserEvent its because we authenticated something invalid
+        Note that in this test, failure to see any UserEvents is a good thing.
+        If we get a UserEvent its because we authenticated something invalid.
         """
         self.passed = False
         if event['result'] == 'pass':
@@ -131,4 +136,4 @@
     return 0
 
 if __name__ == "__main__":
-   sys.exit(main() or 0)
+    sys.exit(main() or 0)
diff --git a/tests/apps/voicemail/authenticate_invalid_password/run-test b/tests/apps/voicemail/authenticate_invalid_password/run-test
index 147b6f7..a8951c3 100755
--- a/tests/apps/voicemail/authenticate_invalid_password/run-test
+++ b/tests/apps/voicemail/authenticate_invalid_password/run-test
@@ -21,10 +21,11 @@
 
 logger = logging.getLogger(__name__)
 
-"""
-TestState that attempts a login with a mailbox / incorrect password
-"""
+
 class LoginWithMailbox(VoiceMailState):
+    """
+    TestState that attempts a login with a mailbox / incorrect password
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -52,10 +53,11 @@
     def get_state_name(self):
         return "LOGIN WITH MAILBOX"
 
-"""
-TestState that attempts a login with an incorrect password only
-"""
+
 class LoginWithoutMailbox(VoiceMailState):
+    """
+    TestState that attempts a login with an incorrect password only
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -81,6 +83,7 @@
     def get_state_name(self):
         return "LOGIN WITHOUT MAILBOX"
 
+
 class AuthenticateInvalidPassword(VoiceMailTest):
 
     def __init__(self):
@@ -91,7 +94,10 @@
     def ami_connect(self, ami):
         super(AuthenticateInvalidPassword, self).ami_connect(ami)
 
-        """ Record which AMI instance we've received and attempt to set up the test controller """
+        """
+        Record which AMI instance we've received and attempt to set up
+        the test controller
+        """
         if (ami.id == 0):
             self.ami_receiver = ami
             ami.registerEvent('UserEvent', self.user_event)
@@ -135,8 +141,8 @@
             return
 
         """
-        Note that in this test, failure to see any UserEvents is a good thing - if we get to a
-        UserEvent its because we authenticated something invalid
+        Note that in this test, failure to see any UserEvents is a good thing.
+        If we get a UserEvent its because we authenticated something invalid.
         """
         self.passed = False
         if event['result'] == 'pass':
@@ -170,4 +176,4 @@
     return 0
 
 if __name__ == "__main__":
-   sys.exit(main() or 0)
+    sys.exit(main() or 0)
diff --git a/tests/apps/voicemail/authenticate_nominal/run-test b/tests/apps/voicemail/authenticate_nominal/run-test
index c643c3d..dba79da 100755
--- a/tests/apps/voicemail/authenticate_nominal/run-test
+++ b/tests/apps/voicemail/authenticate_nominal/run-test
@@ -21,10 +21,11 @@
 
 logger = logging.getLogger(__name__)
 
-"""
-TestState that attempts a login with a mailbox / incorrect password
-"""
+
 class LoginWithMailbox(VoiceMailState):
+    """
+    TestState that attempts a login with a mailbox / incorrect password
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -57,10 +58,11 @@
     def get_state_name(self):
         return "LOGIN WITH MAILBOX"
 
-"""
-TestState that attempts a login with an incorrect password only
-"""
+
 class LoginWithoutMailbox(VoiceMailState):
+    """
+    TestState that attempts a login with an incorrect password only
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -92,17 +94,17 @@
         return "LOGIN WITHOUT MAILBOX"
 
 
-
 class AuthenticateNominal(VoiceMailTest):
-
-
 
     """ Test results for each iterations """
     results = [False, False, False]
 
     def __init__(self):
         super(AuthenticateNominal, self).__init__()
-        """ Each tuple consists of the mailbox, password, expected channel and test controller object type """
+        """
+        Each tuple consists of the mailbox, password, expected channel
+        and test controller object type
+        """
         self.credentials = [
             ("9000", "1234", "SIP/ast1-00000000", LoginWithMailbox),
             ("9001", "0", "SIP/ast1-00000001", LoginWithoutMailbox),
@@ -113,14 +115,17 @@
     def ami_connect(self, ami):
         super(AuthenticateNominal, self).ami_connect(ami)
 
-        """ Record which AMI instance we've received and attempt to set up the test controller """
+        """
+        Record which AMI instance we've received and attempt to set up
+        the test controller
+        """
         if (ami.id == 0):
             self.ami_receiver = ami
             ami.registerEvent('UserEvent', self.user_event)
         elif (ami.id == 1):
             self.ami_sender = ami
             self.ast_sender = self.ast[self.ami_sender.id]
-            #ami.registerEvent('Hangup', self.hangup_event_handler)
+            # ami.registerEvent('Hangup', self.hangup_event_handler)
         self.create_test_controller()
 
         if (self.ami_receiver != None and self.ami_sender != None):
@@ -190,4 +195,4 @@
     return 0
 
 if __name__ == "__main__":
-   sys.exit(main() or 0)
+    sys.exit(main() or 0)
diff --git a/tests/apps/voicemail/check_voicemail_callback/run-test b/tests/apps/voicemail/check_voicemail_callback/run-test
index 47e0f74..62f8e0e 100755
--- a/tests/apps/voicemail/check_voicemail_callback/run-test
+++ b/tests/apps/voicemail/check_voicemail_callback/run-test
@@ -28,10 +28,11 @@
 
 logger = logging.getLogger(__name__)
 
-"""
-TestState that is the entry point for the VoiceMailMain application
-"""
+
 class StartVoiceMailState(VoiceMailState):
+    """
+    TestState that is the entry point for the VoiceMailMain application
+    """
 
     userPassword = "1234#"
 
@@ -54,10 +55,10 @@
         return "START"
 
 
-"""
-TestState that occurs after a user has been authenticated
-"""
 class AuthenticatedTestState(VoiceMailState):
+    """
+    TestState that occurs after a user has been authenticated
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -84,11 +85,11 @@
         return "AUTHENTICATED"
 
 
-"""
-TestState that occurs after when the user is being presented with the initial message counts and the main
-voicemail menu
-"""
 class IntroTestState(VoiceMailState):
+    """
+    TestState that occurs after when the user is being presented with the
+    initial message counts and the main voicemail menu
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -113,10 +114,10 @@
         return "INTRO"
 
 
-"""
-TestState that occurs while the user is browsing through messages
-"""
 class BrowseMessageTestState(VoiceMailState):
+    """
+    TestState that occurs while the user is browsing through messages
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -134,10 +135,10 @@
         return "BROWSE"
 
 
-"""
-TestState that occurs when a user chooses to play a message
-"""
 class AdvancedOptionsTestState(VoiceMailState):
+    """
+    TestState that occurs when a user chooses to play a message
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -164,10 +165,10 @@
         return "ADVOPTIONS"
 
 
-"""
-TestState that occurs when the actual voicemail is being played back to the user
-"""
 class PlayVoiceMailTestState(VoiceMailState):
+    """
+    TestState that occurs when the actual voicemail is being played back to the user
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -194,10 +195,10 @@
         return "PLAYVOICE"
 
 
-"""
-The TestCase class that executes the test
-"""
 class CheckVoicemailCallback(VoiceMailTest):
+    """
+    The TestCase class that executes the test
+    """
 
     """
     The channel to connect to that acts as the voicemail server
@@ -229,7 +230,10 @@
     def ami_connect(self, ami):
         super(CheckVoicemailCallback, self).ami_connect(ami)
 
-        """ Record which AMI instance we've received and attempt to set up the test controller """
+        """
+        Record which AMI instance we've received and attempt to set up the
+        test controller
+        """
         if (ami.id == 0):
             self.ami_receiver = ami
         elif (ami.id == 1):
@@ -244,7 +248,6 @@
 
         """ Now do specific processing on the AMI instances """
         if (ami.id == 0):
-
             ami.registerEvent('UserEvent', self.user_event)
 
             """ Create a dummy voicemail """
@@ -253,10 +256,9 @@
 
             logger.debug("Creating dummy voicemail")
             for i in range(0, 1):
-                if not self.voicemailManager.create_dummy_voicemail("default","1234", VoiceMailMailboxManagement.inbox_folder_name, i, self.formats):
+                if not self.voicemailManager.create_dummy_voicemail("default", "1234", VoiceMailMailboxManagement.inbox_folder_name, i, self.formats):
                     logger.error("Failed to create voicemails in folder " + VoiceMailMailboxManagement.inbox_folder_name)
                     self.stop_reactor()
-
         else:
             logger.debug("Originating call to " + self.channel)
             df = ami.originate(self.channel, "voicemailCaller", "wait", 1)
@@ -307,17 +309,17 @@
     test.stop_asterisk()
 
     """
-    Post-test processing - verify that we listened to all the messages we wanted to listen to, that
-    we saved the messages, and that the messages were moved successfully
+    Post-test processing - verify that we listened to all the messages we wanted
+    to listen to, that we saved the messages, and that the messages were moved
+    successfully
     """
     if test.passed:
-
         if not test.check_test_conditions():
             logger.warn("Test failed condition checks")
             test.passed = False
 
-        formats = ["ulaw","wav","WAV"]
-        if voicemailManager.check_voicemail_exists("default","1234", 0, formats, "INBOX"):
+        formats = ["ulaw", "wav", "WAV"]
+        if voicemailManager.check_voicemail_exists("default", "1234", 0, formats, "INBOX"):
             logger.warn("Voicemail left in INBOX - should have been moved to old")
             test.passed = False
 
@@ -327,4 +329,4 @@
     return 0
 
 if __name__ == "__main__":
-   sys.exit(main() or 0)
+    sys.exit(main() or 0)
diff --git a/tests/apps/voicemail/check_voicemail_envelope/run-test b/tests/apps/voicemail/check_voicemail_envelope/run-test
index 0f2bac5..bd9dcea 100755
--- a/tests/apps/voicemail/check_voicemail_envelope/run-test
+++ b/tests/apps/voicemail/check_voicemail_envelope/run-test
@@ -28,10 +28,11 @@
 
 logger = logging.getLogger(__name__)
 
-"""
-TestState that is the entry point for the VoiceMailMain application
-"""
+
 class StartVoiceMailState(VoiceMailState):
+    """
+    TestState that is the entry point for the VoiceMailMain application
+    """
 
     userPassword = "1234#"
 
@@ -55,10 +56,10 @@
         return "START"
 
 
-"""
-TestState that occurs after a user has been authenticated
-"""
 class AuthenticatedTestState(VoiceMailState):
+    """
+    TestState that occurs after a user has been authenticated
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -83,11 +84,11 @@
         return "AUTHENTICATED"
 
 
-"""
-TestState that occurs after when the user is being presented with the initial message counts and the main
-voicemail menu
-"""
 class IntroTestState(VoiceMailState):
+    """
+    TestState that occurs after when the user is being presented with the initial
+    message counts and the main voicemail menu
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -110,10 +111,10 @@
         return "INTRO"
 
 
-"""
-TestState that occurs when a user chooses to play a message
-"""
 class BrowseMessageTestState(VoiceMailState):
+    """
+    TestState that occurs when a user chooses to play a message
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -145,10 +146,10 @@
         return "BROWSE"
 
 
-"""
-TestState that occurs when the actual voicemail is being played back to the user
-"""
 class PlayVoiceMailTestState(VoiceMailState):
+    """
+    TestState that occurs when the actual voicemail is being played back to the user
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -173,10 +174,10 @@
         return "PLAYVOICE"
 
 
-"""
-TestState that occurs when the voicemail menu for saving a voicemail is being played
-"""
 class SaveMessageTestState(VoiceMailState):
+    """
+    TestState that occurs when the voicemail menu for saving a voicemail is being played
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -204,10 +205,10 @@
         return "SAVEMSG"
 
 
-"""
-TestState that occurs between saving a message and browsing (or playing) the next message
-"""
 class PlayNextMessageTestState(VoiceMailState):
+    """
+    TestState that occurs between saving a message and browsing (or playing) the next message
+    """
 
     def __init__(self, controller, voiceMailTest):
         VoiceMailState.__init__(self, controller, voiceMailTest)
@@ -229,10 +230,10 @@
         return "PLAYNEXT"
 
 
-"""
-The TestCase class that executes the test
-"""
 class CheckVoicemailEnvelope(VoiceMailTest):
+    """
+    The TestCase class that executes the test
+    """
 
     """
     The channel to connect to that acts as the voicemail server
@@ -270,7 +271,10 @@
     def ami_connect(self, ami):
         super(CheckVoicemailEnvelope, self).ami_connect(ami)
 
-        """ Record which AMI instance we've received and attempt to set up the test controller """
+        """
+        Record which AMI instance we've received and attempt to set up the
+        test controller
+        """
         if (ami.id == 0):
             self.ami_receiver = ami
         elif (ami.id == 1):
@@ -285,7 +289,6 @@
 
         """ Now do specific processing on the AMI instances """
         if (ami.id == 0):
-
             ami.registerEvent('UserEvent', self.user_event)
 
             """ Create a dummy voicemail """
@@ -293,10 +296,9 @@
             self.voicemailManager.create_mailbox("default", "1234", True)
 
             logger.debug("Creating dummy voicemail")
-            if not self.voicemailManager.create_dummy_voicemail("default","1234", VoiceMailMailboxManagement.inbox_folder_name, 0, self.formats):
+            if not self.voicemailManager.create_dummy_voicemail("default", "1234", VoiceMailMailboxManagement.inbox_folder_name, 0, self.formats):
                 logger.error("Failed to create voicemails in folder " + VoiceMailMailboxManagement.inbox_folder_name)
                 self.stop_reactor()
-
         else:
             logger.debug("Originating call to " + self.channel)
             df = ami.originate(self.channel, "voicemailCaller", "wait", 1)
@@ -342,8 +344,9 @@
     test.stop_asterisk()
 
     """
-    Post-test processing - verify that we listened to all the messages we wanted to listen to, that
-    we saved the messages, and that the messages were moved successfully
+    Post-test processing - verify that we listened to all the messages we wanted
+    to listen to, that we saved the messages, and that the messages were moved
+    successfully
     """
     if test.passed:
 
@@ -351,11 +354,11 @@
             logger.warn("Test failed condition checks")
             test.passed = False
 
-        formats = ["ulaw","wav","WAV"]
-        if voicemailManager.check_voicemail_exists("default","1234", 0, formats, "INBOX"):
+        formats = ["ulaw", "wav", "WAV"]
+        if voicemailManager.check_voicemail_exists("default", "1234", 0, formats, "INBOX"):
             logger.warn("Voicemail left in INBOX - should have been saved to old")
             test.passed = False
-        if not voicemailManager.check_voicemail_exists("default","1234", 0, formats, "Old"):
+        if not voicemailManager.check_voicemail_exists("default", "1234", 0, formats, "Old"):
             logger.warn("Failed to find voicemail in folder Old")
             test.passed = False
 
@@ -365,4 +368,4 @@
     return 0
 
 if __name__ == "__main__":
-   sys.exit(main() or 0)
+    sys.exit(main() or 0)
diff --git a/tests/apps/voicemail/play_message/run-test b/tests/apps/voicemail/play_message/run-test
index a9e93a8..7a0b657 100755
--- a/tests/apps/voicemail/play_message/run-test
+++ b/tests/apps/voicemail/play_message/run-test
@@ -23,12 +23,13 @@
 
 logger = logging.getLogger(__name__)
 
+
 class PlayMsg(TestCase):
 
     def __init__(self):
         super(PlayMsg, self).__init__()
         self._voicemailManager = None
-        self._formats = ["ulaw","wav","WAV"]
+        self._formats = ["ulaw", "wav", "WAV"]
         self._current_test = 0
         self._tests = []
         self._results = []
@@ -46,17 +47,38 @@
         self.voicemailManager.create_dummy_voicemail("notdefault", "5678", VoiceMailMailboxManagement.urgent_folder_name, 0, self._formats)
 
         # For each of the created voicemails, push a dictionary onto the list containing the information for that test
-        self._tests.append({"context": "default", "mailbox": "1234", "msg_id": self.voicemailManager.created_voicemails[VoiceMailMailboxManagement.inbox_folder_name][0][1], "expected_result": True})
-        self._tests.append({"context": "default", "mailbox": "1234", "msg_id": self.voicemailManager.created_voicemails[VoiceMailMailboxManagement.old_folder_name][0][1], "expected_result": True})
-        self._tests.append({"context": "notdefault", "mailbox": "5678", "msg_id": self.voicemailManager.created_voicemails[VoiceMailMailboxManagement.urgent_folder_name][0][1], "expected_result": True})
+        self._tests.append({"context": "default",
+                            "mailbox": "1234",
+                            "msg_id": self.voicemailManager.created_voicemails[VoiceMailMailboxManagement.inbox_folder_name][0][1],
+                            "expected_result": True})
+        self._tests.append({"context": "default",
+                            "mailbox": "1234",
+                            "msg_id": self.voicemailManager.created_voicemails[VoiceMailMailboxManagement.old_folder_name][0][1],
+                            "expected_result": True})
+        self._tests.append({"context": "notdefault",
+                            "mailbox": "5678",
+                            "msg_id": self.voicemailManager.created_voicemails[VoiceMailMailboxManagement.urgent_folder_name][0][1],
+                            "expected_result": True})
         # Bad message ID
-        self._tests.append({"context": "default", "mailbox": "1234", "msg_id": "12345678", "expected_result": False})
+        self._tests.append({"context": "default",
+                            "mailbox": "1234",
+                            "msg_id": "12345678",
+                            "expected_result": False})
         # Empty mailbox
-        self._tests.append({"context": "default", "mailbox": "", "msg_id": self.voicemailManager.created_voicemails[VoiceMailMailboxManagement.inbox_folder_name][0][1], "expected_result": False})
+        self._tests.append({"context": "default",
+                            "mailbox": "",
+                            "msg_id": self.voicemailManager.created_voicemails[VoiceMailMailboxManagement.inbox_folder_name][0][1],
+                            "expected_result": False})
         # Empty message ID
-        self._tests.append({"context":"default", "mailbox": "1234", "msg_id": "", "expected_result": False})
+        self._tests.append({"context": "default",
+                            "mailbox": "1234",
+                            "msg_id": "",
+                            "expected_result": False})
         # Default context
-        self._tests.append({"context": "", "mailbox": "1234", "msg_id": self.voicemailManager.created_voicemails[VoiceMailMailboxManagement.old_folder_name][0][1], "expected_result": True})
+        self._tests.append({"context": "",
+                            "mailbox": "1234",
+                            "msg_id": self.voicemailManager.created_voicemails[VoiceMailMailboxManagement.old_folder_name][0][1],
+                            "expected_result": True})
 
         ami.registerEvent('TestEvent', self.test_event_handler)
         ami.registerEvent('UserEvent', self.user_event_handler)
@@ -65,10 +87,14 @@
 
     def _start_test(self, ami):
         test = self._tests[self._current_test]
-        logger.debug("Setting context=%s; mailbox=%s; msgid=%s" % (test["context"], test["mailbox"], test["msg_id"]))
-        variable_value = '%s,MAILBOX=%s,MSGID=%s' % (test['context'], test['mailbox'], test['msg_id'])
-        ami.originate(channel = "Local/playmsg at voicemail", application = "Echo",
-            variable={"MAILCONTEXT": variable_value}).addErrback(self.handle_originate_failure)
+        logger.debug("Setting context=%s; mailbox=%s; msgid=%s" % (test["context"],
+                                                                   test["mailbox"],
+                                                                   test["msg_id"]))
+        variable_value = '%s,MAILBOX=%s,MSGID=%s' % (test['context'],
+                                                     test['mailbox'],
+                                                     test['msg_id'])
+        ami.originate(channel="Local/playmsg at voicemail", application="Echo",
+                      variable={"MAILCONTEXT": variable_value}).addErrback(self.handle_originate_failure)
 
     def test_event_handler(self, ami, event):
         if 'state' in event and 'message' in event:
@@ -105,6 +131,7 @@
         super(PlayMsg, self).run()
         self.create_ami_factory()
 
+
 def main():
 
     test = PlayMsg()
@@ -116,4 +143,4 @@
     return 0
 
 if __name__ == "__main__":
-   sys.exit(main() or 0)
+    sys.exit(main() or 0)

-- 
To view, visit https://gerrit.asterisk.org/6063
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I74e198aeec42bca908141dead9c0fe23d6f63659
Gerrit-Change-Number: 6063
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170721/7d1e4236/attachment-0001.html>


More information about the asterisk-code-review mailing list