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