[Asterisk-code-review] tests/rest api: Fix PEP 8 compliance issues (testsuite[master])
Matt Jordan
asteriskteam at digium.com
Sat Jul 25 17:08:11 CDT 2015
Matt Jordan has uploaded a new change for review.
https://gerrit.asterisk.org/968
Change subject: tests/rest_api: Fix PEP 8 compliance issues
......................................................................
tests/rest_api: Fix PEP 8 compliance issues
This patch fixes issues caught by the pep8 utility. It contains no
semantic changes, and for the most part adjusts whitespace.
Change-Id: I4950056e10d8ffc1fca12fece432a112117aa353
---
M tests/rest_api/applications/channel-subscriptions/basic_subscription/subscribe_channel.py
M tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py
M tests/rest_api/applications/errors/errors.py
M tests/rest_api/applications/stasisstatus/ari_client.py
M tests/rest_api/applications/stasisstatus/monitor.py
M tests/rest_api/applications/stasisstatus/observable_object.py
M tests/rest_api/applications/stasisstatus/test_scenario.py
M tests/rest_api/applications/subscribe-bridge/subscribe_bridge.py
M tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py
M tests/rest_api/applications/subscribe-endpoint/subscriber.py
M tests/rest_api/bridges/add_recording_channel/add_recording_channel.py
M tests/rest_api/bridges/hangup/bridge_hangup.py
M tests/rest_api/bridges/happy/bridge_happy.py
M tests/rest_api/bridges/playback/tones/bridges_play.py
M tests/rest_api/bridges/unhappy/bridge_unhappy.py
M tests/rest_api/channels/originate/channel_originate.py
M tests/rest_api/channels/originate_with_vars/originate_with_vars.py
M tests/rest_api/channels/snoop_spy/channel_spy.py
M tests/rest_api/channels/snoop_whisper/channel_whisper.py
M tests/rest_api/continue/rest_continue.py
M tests/rest_api/danger/dangerous/dangerous.py
M tests/rest_api/danger/safe/safe.py
M tests/rest_api/device_state/add_invalid/device_state.py
M tests/rest_api/device_state/add_remove/device_state.py
M tests/rest_api/device_state/change/device_state.py
M tests/rest_api/device_state/list/device_state.py
M tests/rest_api/external_interaction/attended_transfer/attended_transfer.py
M tests/rest_api/external_interaction/blind_transfer/call_transfer.py
M tests/rest_api/external_interaction/blind_transfer/stasis_bridge_to_non_stasis_app/blind_transfer.py
M tests/rest_api/mailbox/baseline/mailbox_baseline.py
M tests/rest_api/message/message_modules.py
M tests/rest_api/recording/nominal/recording.py
M tests/rest_api/recording/stored/copy/nominal/recording.py
M tests/rest_api/recording/stored/copy/off-nominal/recording.py
34 files changed, 132 insertions(+), 67 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/68/968/1
diff --git a/tests/rest_api/applications/channel-subscriptions/basic_subscription/subscribe_channel.py b/tests/rest_api/applications/channel-subscriptions/basic_subscription/subscribe_channel.py
index e1feebd..c123f55 100644
--- a/tests/rest_api/applications/channel-subscriptions/basic_subscription/subscribe_channel.py
+++ b/tests/rest_api/applications/channel-subscriptions/basic_subscription/subscribe_channel.py
@@ -10,6 +10,7 @@
LOGGER = logging.getLogger(__name__)
+
class TestData(object):
def __init__(self):
self.channel_id = None
diff --git a/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py b/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py
index 80a61a8..db9dbea 100755
--- a/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py
+++ b/tests/rest_api/applications/double-subscribe-device-state/subscribe_device_state.py
@@ -11,6 +11,7 @@
INITIAL_STATE = 'NOT_INUSE'
CHANGED_STATE = 'INUSE'
+
def on_start(ari, event, obj):
# add a device state
ari.put(URL, DEVICE, deviceState=INITIAL_STATE)
@@ -28,7 +29,7 @@
# unsubscribe from device
ari.delete("applications", "testsuite", "subscription",
- eventSource="deviceState:%s" % DEVICE)
+ eventSource="deviceState:%s" % DEVICE)
# remove device
ari.delete(URL, DEVICE)
@@ -36,6 +37,7 @@
ari.delete('channels', event['channel']['id'])
return True
+
def on_state_change(ari, event, obj):
assert event['device_state']['name'] == DEVICE
assert event['device_state']['state'] == CHANGED_STATE
diff --git a/tests/rest_api/applications/errors/errors.py b/tests/rest_api/applications/errors/errors.py
index 88861e8..78addba 100644
--- a/tests/rest_api/applications/errors/errors.py
+++ b/tests/rest_api/applications/errors/errors.py
@@ -30,7 +30,6 @@
assert 1 == len(app_list)
assert 'testsuite' == app_list[0].get('name')
-
ari.set_allow_errors(True)
resp = ari.get('applications', 'notanapp')
@@ -43,19 +42,19 @@
validate('bad_request', resp)
resp = ari.post('applications', 'testsuite', 'subscription',
- eventSource='notascheme:foo')
+ eventSource='notascheme:foo')
validate('bad_request', resp)
resp = ari.delete('applications', 'testsuite', 'subscription',
- eventSource='notascheme:foo')
+ eventSource='notascheme:foo')
validate('bad_request', resp)
resp = ari.post('applications', 'testsuite', 'subscription',
- eventSource='channel:notachannel')
+ eventSource='channel:notachannel')
validate('unprocessable_entity', resp)
resp = ari.delete('applications', 'testsuite', 'subscription',
- eventSource='channel:notachannel')
+ eventSource='channel:notachannel')
validate('unprocessable_entity', resp)
ari.post('channels', channel_id, 'continue')
diff --git a/tests/rest_api/applications/stasisstatus/ari_client.py b/tests/rest_api/applications/stasisstatus/ari_client.py
index e7e2eb3..e75f99a 100644
--- a/tests/rest_api/applications/stasisstatus/ari_client.py
+++ b/tests/rest_api/applications/stasisstatus/ari_client.py
@@ -42,8 +42,6 @@
name -- The name of the app to register in Stasis via
ARI (optional) (default 'testsuite').
"""
-
-
super(AriClient, self).__init__(name, ['on_channelcreated',
'on_channeldestroyed',
'on_channelvarset',
diff --git a/tests/rest_api/applications/stasisstatus/monitor.py b/tests/rest_api/applications/stasisstatus/monitor.py
index 4504ac3..c71c2a5 100644
--- a/tests/rest_api/applications/stasisstatus/monitor.py
+++ b/tests/rest_api/applications/stasisstatus/monitor.py
@@ -33,7 +33,7 @@
"""
super(ChannelVariableMonitor, self).__init__(name,
- ['on_value_changed'])
+ ['on_value_changed'])
self.__ami = ami
self.__captured_value = None
self.__channel_variable = variable
@@ -120,4 +120,3 @@
self.__channel_variable,
self.__captured_value))
self.notify_observers('on_value_changed', None, False)
-
diff --git a/tests/rest_api/applications/stasisstatus/observable_object.py b/tests/rest_api/applications/stasisstatus/observable_object.py
index 20f62f0..c38e555 100644
--- a/tests/rest_api/applications/stasisstatus/observable_object.py
+++ b/tests/rest_api/applications/stasisstatus/observable_object.py
@@ -15,6 +15,7 @@
LOGGER = logging.getLogger(__name__)
+
class ObservableObject(object):
"""Definition for an observable object."""
diff --git a/tests/rest_api/applications/stasisstatus/test_scenario.py b/tests/rest_api/applications/stasisstatus/test_scenario.py
index be284db..6d0f955 100644
--- a/tests/rest_api/applications/stasisstatus/test_scenario.py
+++ b/tests/rest_api/applications/stasisstatus/test_scenario.py
@@ -72,10 +72,10 @@
passed = self.actual_value == self.expected_value
LOGGER.debug('{0} Test strategy is complete.'.format(self))
- LOGGER.debug('{0} Test values: Expected [{1}]; Actual [{2}].' \
- .format(self, self.expected_value, self.actual_value))
- LOGGER.debug('{0} Test results: Test {1}.' \
- .format(self, 'Passed' if passed else 'Did Not Pass'))
+ LOGGER.debug('{0} Test values: Expected [{1}]; Actual [{2}].'
+ .format(self, self.expected_value, self.actual_value))
+ LOGGER.debug('{0} Test results: Test {1}.'
+ .format(self, 'Passed' if passed else 'Did Not Pass'))
self.passed = passed
@@ -137,7 +137,7 @@
"""Overrides the default behavior of resetting the value of the
suspended flag."""
- #Run the 'resume' logic first, then do the delayed check.
+ # Run the 'resume' logic first, then do the delayed check.
if self.suspended:
super(TestScenario, self).resume()
self.__monitor.resume()
diff --git a/tests/rest_api/applications/subscribe-bridge/subscribe_bridge.py b/tests/rest_api/applications/subscribe-bridge/subscribe_bridge.py
index 6e1f940..2f6a982 100644
--- a/tests/rest_api/applications/subscribe-bridge/subscribe_bridge.py
+++ b/tests/rest_api/applications/subscribe-bridge/subscribe_bridge.py
@@ -10,6 +10,7 @@
LOGGER = logging.getLogger(__name__)
+
class SubscribeBridge(object):
def __init__(self):
self.channels = None
@@ -17,6 +18,7 @@
TEST = SubscribeBridge()
+
def on_start(ari, event, test_object):
TEST.channel_id = event['channel']['id']
@@ -33,6 +35,7 @@
channel=TEST.channel_id)
return True
+
def on_enter_testsuite(ari, event, test_object):
# the testsuite application received a ChannelEnteredBridge event
assert TEST.bridge_id == event['bridge']['id']
@@ -40,7 +43,7 @@
# now unsubscribe testsuite from the bridge-watching-app
ari.delete('applications', 'bridge-watching-app', 'subscription',
- eventSource='bridge:%s' % TEST.bridge_id)
+ eventSource='bridge:%s' % TEST.bridge_id)
# upon removing the channel testsuite should receive no event, but
# the still subscribed bridge-watching-app should
@@ -48,6 +51,7 @@
channel=TEST.channel_id)
return True
+
def on_channel_left_bridge(ari, event, test_object):
# bridge-watching-app received a ChannelLeftBridge event
assert TEST.bridge_id == event['bridge']['id']
diff --git a/tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py b/tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py
index e359f4b..051783d 100644
--- a/tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py
+++ b/tests/rest_api/applications/subscribe-device-state/subscribe_device_state.py
@@ -11,6 +11,7 @@
INITIAL_STATE = 'NOT_INUSE'
CHANGED_STATE = 'INUSE'
+
def on_start(ari, event, test_obj):
# add a device state
ari.put(URL, DEVICE, deviceState=INITIAL_STATE)
@@ -24,7 +25,7 @@
# unsubscribe from device
ari.delete("applications", "testsuite", "subscription",
- eventSource="deviceState:%s" % DEVICE)
+ eventSource="deviceState:%s" % DEVICE)
# remove device
ari.delete(URL, DEVICE)
@@ -32,6 +33,7 @@
ari.delete('channels', event['channel']['id'])
return True
+
def on_state_change(ari, event, test_obj):
assert event['device_state']['name'] == DEVICE
assert event['device_state']['state'] == CHANGED_STATE
diff --git a/tests/rest_api/applications/subscribe-endpoint/subscriber.py b/tests/rest_api/applications/subscribe-endpoint/subscriber.py
index 6f01317..e629de4 100644
--- a/tests/rest_api/applications/subscribe-endpoint/subscriber.py
+++ b/tests/rest_api/applications/subscribe-endpoint/subscriber.py
@@ -11,6 +11,7 @@
LOGGER = logging.getLogger(__name__)
+
class ResourceSubscription(object):
"""Pluggable module that subscribes to a resource"""
@@ -54,11 +55,11 @@
if expected_response:
if resp.status_code != expected_response:
LOGGER.error('Failed to get expected response %d: Got %d' %
- (expected_response, resp.status_code))
+ (expected_response, resp.status_code))
self.test_object.set_passed(False)
else:
LOGGER.info('Got expected response %d for %s' %
- (expected_response, sub['event-source']))
+ (expected_response, sub['event-source']))
self.test_object.set_passed(True)
ari.set_allow_errors(False)
diff --git a/tests/rest_api/bridges/add_recording_channel/add_recording_channel.py b/tests/rest_api/bridges/add_recording_channel/add_recording_channel.py
index 3fb2dc7..7557e3e 100644
--- a/tests/rest_api/bridges/add_recording_channel/add_recording_channel.py
+++ b/tests/rest_api/bridges/add_recording_channel/add_recording_channel.py
@@ -8,6 +8,7 @@
import requests
+
def on_start(ari, event, obj):
channel_id = event['channel']['id']
diff --git a/tests/rest_api/bridges/hangup/bridge_hangup.py b/tests/rest_api/bridges/hangup/bridge_hangup.py
index b58802e..cc3dacc 100644
--- a/tests/rest_api/bridges/hangup/bridge_hangup.py
+++ b/tests/rest_api/bridges/hangup/bridge_hangup.py
@@ -30,7 +30,7 @@
def on_stop(ari, event, test_object):
- LOGGER.debug("on_stop(%r)" %event)
+ LOGGER.debug("on_stop(%r)" % event)
ari.delete('bridges', TEST.bridge_id)
return True
diff --git a/tests/rest_api/bridges/happy/bridge_happy.py b/tests/rest_api/bridges/happy/bridge_happy.py
index 5cdefea..cd04781 100644
--- a/tests/rest_api/bridges/happy/bridge_happy.py
+++ b/tests/rest_api/bridges/happy/bridge_happy.py
@@ -30,7 +30,7 @@
def on_stop(ari, event, test_object):
- LOGGER.debug("on_stop(%r)" %event)
+ LOGGER.debug("on_stop(%r)" % event)
ari.delete('bridges', TEST.bridge_id)
return True
diff --git a/tests/rest_api/bridges/playback/tones/bridges_play.py b/tests/rest_api/bridges/playback/tones/bridges_play.py
index 3313e36..646fe68 100755
--- a/tests/rest_api/bridges/playback/tones/bridges_play.py
+++ b/tests/rest_api/bridges/playback/tones/bridges_play.py
@@ -18,6 +18,7 @@
BRIDGE_ID = 'test-tones-bridge'
TEST = SubscribeBridge()
+
def on_start(ari, event, test_object):
""" When the channel enters stasis, create a bridge and add the channel. """
TEST.channel_id = event['channel']['id']
diff --git a/tests/rest_api/bridges/unhappy/bridge_unhappy.py b/tests/rest_api/bridges/unhappy/bridge_unhappy.py
index 4d0673d..4a017d5 100644
--- a/tests/rest_api/bridges/unhappy/bridge_unhappy.py
+++ b/tests/rest_api/bridges/unhappy/bridge_unhappy.py
@@ -151,8 +151,8 @@
resp = ari.post('bridges', bridge_id, 'removeChannel',
channel=self.stasis_channel_id)
resp.raise_for_status()
- ari.delete('bridges', bridge_id);
- ari.delete('bridges', other_bridge_id);
+ ari.delete('bridges', bridge_id)
+ ari.delete('bridges', other_bridge_id)
TEST = BridgeUnhappy()
diff --git a/tests/rest_api/channels/originate/channel_originate.py b/tests/rest_api/channels/originate/channel_originate.py
index f253ff2..af1586c 100644
--- a/tests/rest_api/channels/originate/channel_originate.py
+++ b/tests/rest_api/channels/originate/channel_originate.py
@@ -12,23 +12,29 @@
CHANNELS = 0
+
def on_kickoff_start(ari, event, test_object):
LOGGER.debug("on_kickoff_start(%r)" % event)
for x in xrange(25):
- ari.post('channels', endpoint='Local/1000 at default', app='testsuite', appArgs='blast')
+ ari.post('channels',
+ endpoint='Local/1000 at default',
+ app='testsuite',
+ appArgs='blast')
ari.delete('channels', event['channel']['id'])
return True
+
def on_blast_start(ari, event, test_object):
LOGGER.debug("on_blast_start(%r)" % event)
return True
+
def on_channel_destroyed(ari, event, test_object):
- global CHANNELS
- LOGGER.debug("on_channel_destroyed: %s" % str(event.get('channel')))
- CHANNELS += 1
- if CHANNELS == 50:
- LOGGER.info("All channels destroyed")
- test_object.set_passed(True)
- test_object.stop_reactor()
- return True
+ global CHANNELS
+ LOGGER.debug("on_channel_destroyed: %s" % str(event.get('channel')))
+ CHANNELS += 1
+ if CHANNELS == 50:
+ LOGGER.info("All channels destroyed")
+ test_object.set_passed(True)
+ test_object.stop_reactor()
+ return True
diff --git a/tests/rest_api/channels/originate_with_vars/originate_with_vars.py b/tests/rest_api/channels/originate_with_vars/originate_with_vars.py
index 837cccc..b2f517a 100644
--- a/tests/rest_api/channels/originate_with_vars/originate_with_vars.py
+++ b/tests/rest_api/channels/originate_with_vars/originate_with_vars.py
@@ -9,12 +9,13 @@
import json
import requests
+
def on_start(ari, event, obj):
url = ari.build_url('channels')
params = {
'endpoint': 'Local/1000 at default',
- 'app':'testsuite',
+ 'app': 'testsuite',
'appArgs': 'with_vars'}
data = {'variables': {'CALLERID(name)': 'foo'}}
diff --git a/tests/rest_api/channels/snoop_spy/channel_spy.py b/tests/rest_api/channels/snoop_spy/channel_spy.py
index 8a3a254..071120a 100644
--- a/tests/rest_api/channels/snoop_spy/channel_spy.py
+++ b/tests/rest_api/channels/snoop_spy/channel_spy.py
@@ -10,31 +10,42 @@
LOGGER = logging.getLogger(__name__)
+
class Snoop(object):
def __init__(self):
self.bridge_id = None
self.stops = 0
+
TEST = Snoop()
+
def on_start(ari, event, test_object):
LOGGER.debug("on_start(%r)" % event)
- ari.post('channels', event['channel']['id'], 'snoop', spy='in', whisper='none', app='testsuite', appArgs='snoop')
- ari.post('channels', event['channel']['id'], 'play', media='sound:demo-congrats')
+ ari.post('channels', event['channel']['id'], 'snoop',
+ spy='in', whisper='none', app='testsuite', appArgs='snoop')
+ ari.post('channels', event['channel']['id'], 'play',
+ media='sound:demo-congrats')
return True
+
def on_snoop_start(ari, event, test_object):
LOGGER.debug("on_snoop_start(%r)" % event)
TEST.bridge_id = ari.post('bridges').json()['id']
- ari.post('bridges', TEST.bridge_id, 'addChannel', channel=event['channel']['id'])
- ari.post('channels', endpoint='Local/amd at default', app='testsuite', appArgs='amd')
+ ari.post('bridges', TEST.bridge_id, 'addChannel',
+ channel=event['channel']['id'])
+ ari.post('channels', endpoint='Local/amd at default',
+ app='testsuite', appArgs='amd')
return True
+
def on_amd_start(ari, event, test_object):
LOGGER.debug("on_amd_start(%r)" % event)
- ari.post('bridges', TEST.bridge_id, 'addChannel', channel=event['channel']['id'])
+ ari.post('bridges', TEST.bridge_id, 'addChannel',
+ channel=event['channel']['id'])
return True
+
def on_end(ari, event, test_object):
LOGGER.debug("on_end(%r)" % event)
TEST.stops += 1
diff --git a/tests/rest_api/channels/snoop_whisper/channel_whisper.py b/tests/rest_api/channels/snoop_whisper/channel_whisper.py
index 500d221..a343289 100644
--- a/tests/rest_api/channels/snoop_whisper/channel_whisper.py
+++ b/tests/rest_api/channels/snoop_whisper/channel_whisper.py
@@ -10,13 +10,18 @@
LOGGER = logging.getLogger(__name__)
+
def on_start(ari, event, test_object):
LOGGER.debug("on_start(%r)" % event)
- ari.post('channels', event['channel']['id'], 'snoop', spy='none', whisper='out', app='testsuite', appArgs='snoop')
- ari.post('channels', event['channel']['id'], 'play', media='sound:silence/10')
+ ari.post('channels', event['channel']['id'], 'snoop',
+ spy='none', whisper='out', app='testsuite', appArgs='snoop')
+ ari.post('channels', event['channel']['id'], 'play',
+ media='sound:silence/10')
return True
+
def on_snoop_start(ari, event, test_object):
LOGGER.debug("on_snoop_start(%r)" % event)
- ari.post('channels', event['channel']['id'], 'play', media='sound:demo-congrats')
+ ari.post('channels', event['channel']['id'], 'play',
+ media='sound:demo-congrats')
return True
diff --git a/tests/rest_api/continue/rest_continue.py b/tests/rest_api/continue/rest_continue.py
index f1d5858..1054b25 100644
--- a/tests/rest_api/continue/rest_continue.py
+++ b/tests/rest_api/continue/rest_continue.py
@@ -83,13 +83,14 @@
CURRENT_EVENT = 0
+
def on_start(ari, event, test_object):
location = event['args'][0]
global CURRENT_EVENT
if location != EXPECTATIONS[CURRENT_EVENT]:
LOGGER.error("Stasis entered from {0}, expected {1}".format(location,
- EXPECTATIONS[CURRENT_EVENT]))
+ EXPECTATIONS[CURRENT_EVENT]))
return False
LOGGER.info("Stasis entered from expected location {0}".format(location))
@@ -102,6 +103,7 @@
**CONTINUATIONS[CURRENT_EVENT])
return True
+
def on_end(ari, event, test_object):
# We don't really care about StasisEnd until the final one
if CURRENT_EVENT == len(CONTINUATIONS):
diff --git a/tests/rest_api/danger/dangerous/dangerous.py b/tests/rest_api/danger/dangerous/dangerous.py
index 52f5a4c..5ffea30 100644
--- a/tests/rest_api/danger/dangerous/dangerous.py
+++ b/tests/rest_api/danger/dangerous/dangerous.py
@@ -10,11 +10,13 @@
LOGGER = logging.getLogger(__name__)
+
def eq(expected, actual):
if expected != actual:
LOGGER.error("Unexpected response '%s' != '%s'" % (expected, actual))
raise ValueError("Test failed")
+
def get_vars(ari, channel_id):
resp = ari.get('channels', channel_id, 'variable', variable='DP_SHELL')
actual = resp.json()["value"]
diff --git a/tests/rest_api/danger/safe/safe.py b/tests/rest_api/danger/safe/safe.py
index d0f14b3..18ee899 100644
--- a/tests/rest_api/danger/safe/safe.py
+++ b/tests/rest_api/danger/safe/safe.py
@@ -15,11 +15,13 @@
from version import AsteriskVersion
+
def eq(expected, actual):
if expected != actual:
LOGGER.error("Unexpected response '%s' != '%s'" % (expected, actual))
raise ValueError("Test failed")
+
def get_vars(ari, channel_id):
resp = ari.get('channels', channel_id, 'variable', variable='DP_SHELL')
actual = resp.json()["value"]
diff --git a/tests/rest_api/device_state/add_invalid/device_state.py b/tests/rest_api/device_state/add_invalid/device_state.py
index 9e842b5..5a0c55e 100644
--- a/tests/rest_api/device_state/add_invalid/device_state.py
+++ b/tests/rest_api/device_state/add_invalid/device_state.py
@@ -13,6 +13,7 @@
MISSING_DEVICE = 'Stasis:'
INITIAL_STATE = 'NOT_INUSE'
+
def on_start(ari, event, obj):
try:
ari.put(URL, INVALID_DEVICE, deviceState=INITIAL_STATE)
diff --git a/tests/rest_api/device_state/add_remove/device_state.py b/tests/rest_api/device_state/add_remove/device_state.py
index df877b1..315bf69 100644
--- a/tests/rest_api/device_state/add_remove/device_state.py
+++ b/tests/rest_api/device_state/add_remove/device_state.py
@@ -12,6 +12,7 @@
DEVICE = 'Stasis:Test'
INITIAL_STATE = 'NOT_INUSE'
+
def on_start(ari, event, obj):
ari.put(URL, DEVICE, deviceState=INITIAL_STATE)
assert ari.get(URL, DEVICE).json()['state'] == INITIAL_STATE
diff --git a/tests/rest_api/device_state/change/device_state.py b/tests/rest_api/device_state/change/device_state.py
index 3799c92..731d613 100644
--- a/tests/rest_api/device_state/change/device_state.py
+++ b/tests/rest_api/device_state/change/device_state.py
@@ -13,6 +13,7 @@
INITIAL_STATE = 'NOT_INUSE'
CHANGED_STATE = 'INUSE'
+
def on_start(ari, event, obj):
ari.put(URL, DEVICE, deviceState=INITIAL_STATE)
assert ari.get(URL, DEVICE).json()['state'] == INITIAL_STATE
diff --git a/tests/rest_api/device_state/list/device_state.py b/tests/rest_api/device_state/list/device_state.py
index af488c1..09f39cb 100644
--- a/tests/rest_api/device_state/list/device_state.py
+++ b/tests/rest_api/device_state/list/device_state.py
@@ -13,6 +13,7 @@
DEVICE2 = 'Stasis:Test2'
INITIAL_STATE = 'NOT_INUSE'
+
def on_start(ari, event, obj):
ari.put(URL, DEVICE1, deviceState=INITIAL_STATE)
ari.put(URL, DEVICE2, deviceState=INITIAL_STATE)
diff --git a/tests/rest_api/external_interaction/attended_transfer/attended_transfer.py b/tests/rest_api/external_interaction/attended_transfer/attended_transfer.py
index 1be23fb..422ed74 100755
--- a/tests/rest_api/external_interaction/attended_transfer/attended_transfer.py
+++ b/tests/rest_api/external_interaction/attended_transfer/attended_transfer.py
@@ -14,6 +14,7 @@
LOGGER = logging.getLogger(__name__)
+
def on_kickoff_start(test_object, triggered_by, ari, event):
LOGGER.debug("on_kickoff_start(%r)" % event)
@@ -21,9 +22,15 @@
referer_scenario.run(test_object)
sipp_referer = SIPpScenario(test_object.test_name,
- {'scenario':'referer.xml', '-p':'5065', '-3pcc':'127.0.0.1:5064'}, target='127.0.0.1')
+ {'scenario': 'referer.xml',
+ '-p': '5065',
+ '-3pcc': '127.0.0.1:5064'},
+ target='127.0.0.1')
sipp_referee = SIPpScenario(test_object.test_name,
- {'scenario':'referee.xml', '-p':'5066', '-3pcc':'127.0.0.1:5064'}, target='127.0.0.1')
+ {'scenario': 'referee.xml',
+ '-p': '5066',
+ '-3pcc': '127.0.0.1:5064'},
+ target='127.0.0.1')
sipp_referee.run(test_object)
@@ -35,4 +42,3 @@
reactor.callLater(3, _start_referer_scenario, sipp_referer, test_object)
return True
-
diff --git a/tests/rest_api/external_interaction/blind_transfer/call_transfer.py b/tests/rest_api/external_interaction/blind_transfer/call_transfer.py
index f1de8be..b853103 100755
--- a/tests/rest_api/external_interaction/blind_transfer/call_transfer.py
+++ b/tests/rest_api/external_interaction/blind_transfer/call_transfer.py
@@ -52,7 +52,7 @@
URI[account['name']]['call_uri'] = account.get('call_uri')
if account.get('transfer_uri') is not None:
URI[account['name']]['transfer_uri'] = \
- account.get('transfer_uri')
+ account.get('transfer_uri')
LOGGER.info("Pluggable module initialized.")
@@ -74,7 +74,7 @@
"""Transfer the call."""
try:
LOGGER.info("'%s' is blind transfering the call to '%s'." %
- (self.call.info().uri, URI['alice']['transfer_uri']))
+ (self.call.info().uri, URI['alice']['transfer_uri']))
self.call.transfer(URI['alice']['transfer_uri'])
except:
LOGGER.warn("Failed to transfer the call! Retrying...")
@@ -174,6 +174,7 @@
except pj.Error, err:
LOGGER.error("Exception: %s" % str(err))
+
def log_call_info(call_info):
"""Log call info."""
LOGGER.debug("Call '%s' <-> '%s'" % (call_info.uri, call_info.remote_uri))
@@ -181,6 +182,7 @@
(call_info.state_text,
call_info.last_code,
call_info.last_reason))
+
def exec_pjsua(test_object, triggered_by, ari, events):
"""Callback method upon ARI event trigger.
@@ -206,6 +208,7 @@
return True
+
def pjsua_initialized(test_object, accounts):
"""Callback method upon all PJSUA endpoints being registered.
diff --git a/tests/rest_api/external_interaction/blind_transfer/stasis_bridge_to_non_stasis_app/blind_transfer.py b/tests/rest_api/external_interaction/blind_transfer/stasis_bridge_to_non_stasis_app/blind_transfer.py
index 01e9316..7625a2e 100755
--- a/tests/rest_api/external_interaction/blind_transfer/stasis_bridge_to_non_stasis_app/blind_transfer.py
+++ b/tests/rest_api/external_interaction/blind_transfer/stasis_bridge_to_non_stasis_app/blind_transfer.py
@@ -11,24 +11,29 @@
LOGGER = logging.getLogger(__name__)
+
class TestLogic(object):
def __init__(self):
self.channels = 0
self.bridge_id = None
self.originated_id = None
self.pja = subprocess.Popen(['pjsua', '--local-port=5065', '--null-audio',
- '--id=sip:bob at 127.0.0.1'],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ '--id=sip:bob at 127.0.0.1'],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+
TEST = TestLogic()
+
def a_call_stasis():
TEST.pja.stdin.write("m\n")
TEST.pja.stdin.write("sip:stasis at 127.0.0.1:5060\n")
+
def a_call_transfer():
TEST.pja.stdin.write("x\n")
TEST.pja.stdin.write("sip:1000 at 127.0.0.1:5060\n")
+
def on_kickoff_start(ari, event, test_object):
LOGGER.debug("on_kickoff_start(%r)" % event)
@@ -40,11 +45,13 @@
a_call_stasis()
return True
+
def on_test_start(ari, event, test_object):
LOGGER.debug("on_test_start(%r)" % event)
ari.post('bridges', TEST.bridge_id, 'addChannel', channel=event['channel']['id'])
return True
+
def on_channel_entered_bridge(ari, event, test_object):
@@ -54,11 +61,13 @@
return True
+
def on_replace_channel_enter(ari, event, test_object):
ari.delete('channels', event['channel']['id'])
ari.delete('channels', TEST.originated_id)
ari.delete('bridges', TEST.bridge_id)
return True
+
def on_blind_transfer(ari, event, test_object):
LOGGER.debug("on_blind_transfer(%r)" % event)
@@ -80,4 +89,3 @@
return False
return True
-
diff --git a/tests/rest_api/mailbox/baseline/mailbox_baseline.py b/tests/rest_api/mailbox/baseline/mailbox_baseline.py
index e028b0a..4e45462 100755
--- a/tests/rest_api/mailbox/baseline/mailbox_baseline.py
+++ b/tests/rest_api/mailbox/baseline/mailbox_baseline.py
@@ -6,11 +6,11 @@
the GNU General Public License Version 2.
'''
-import requests
import logging
import operator
LOGGER = logging.getLogger(__name__)
+
def on_start(ari, event, obj):
mailboxes = ari.get('mailboxes').json()
@@ -21,7 +21,7 @@
ari.put('mailboxes', 'alice_mailbox', oldMessages='3', newMessages='4')
ari.put('mailboxes', 'bob_mailbox', oldMessages='5', newMessages='6')
- LOGGER.info("Successfully added mailboxes");
+ LOGGER.info("Successfully added mailboxes")
# Get a specific mailbox
mailbox = ari.get('mailboxes', 'alice_mailbox').json()
diff --git a/tests/rest_api/message/message_modules.py b/tests/rest_api/message/message_modules.py
index 3156c48..7bf98b1 100644
--- a/tests/rest_api/message/message_modules.py
+++ b/tests/rest_api/message/message_modules.py
@@ -20,6 +20,7 @@
LOGGER = logging.getLogger(__name__)
+
class MessageCoordinator(object):
"""Coordinater for sending/receiving messages
@@ -96,17 +97,16 @@
if expected_response:
if resp.status_code != expected_response:
LOGGER.error('Failed to get expected response %d: Got %d' %
- (expected_response, resp.status_code))
+ (expected_response, resp.status_code))
self.test_object.set_passed(False)
else:
LOGGER.info('Got expected response %d for sub to %s' %
- (expected_response, sub['event-source']))
+ (expected_response, sub['event-source']))
self.test_object.set_passed(True)
ari.set_allow_errors(False)
coordinator = MessageCoordinator.get_instance()
coordinator.poke_observers()
-
class MessageSender(object):
@@ -147,13 +147,13 @@
headers = None
params = message.get('params')
if 'variables' in message:
- data = json.dumps({ 'variables': message['variables'] })
- headers = { 'Content-Type': 'application/json' }
+ data = json.dumps({'variables': message['variables']})
+ headers = {'Content-Type': 'application/json'}
LOGGER.info('PUT %s %s %s' %
- (url, params, data if data else ""))
+ (url, params, data if data else ""))
resp = requests.put(url, params=params, data=data,
- headers=headers, auth=ari.userpass)
+ headers=headers, auth=ari.userpass)
class SIPMessageRunner(object):
@@ -185,7 +185,7 @@
"""
if len(self.scenarios):
LOGGER.error("We still have %d SIPp scenarios running!" %
- len(self.scenarios))
+ len(self.scenarios))
self.test_object.set_passed(False)
for scenario in self.scenarios:
try:
diff --git a/tests/rest_api/recording/nominal/recording.py b/tests/rest_api/recording/nominal/recording.py
index 86d5107..e6551da 100644
--- a/tests/rest_api/recording/nominal/recording.py
+++ b/tests/rest_api/recording/nominal/recording.py
@@ -56,6 +56,7 @@
return True
+
def on_recording_started(ari, event, test_object):
LOGGER.info("Recording started")
@@ -97,6 +98,7 @@
return True
+
def on_recording_finished(ari, event, test_object):
LOGGER.info("Recording finished")
@@ -117,4 +119,4 @@
fail_test()
return
- return True
\ No newline at end of file
+ return True
diff --git a/tests/rest_api/recording/stored/copy/nominal/recording.py b/tests/rest_api/recording/stored/copy/nominal/recording.py
index eb9ca98..89312a1 100644
--- a/tests/rest_api/recording/stored/copy/nominal/recording.py
+++ b/tests/rest_api/recording/stored/copy/nominal/recording.py
@@ -13,6 +13,7 @@
LOGGER = logging.getLogger(__name__)
+
class TestLogic(object):
"""A small object used to hold test data between events"""
@@ -58,6 +59,7 @@
LOGGER.info("Baseline recording started successfully.")
return True
+
def on_recording_started(ari, event, test_object):
"""Handler for the RecordingStarted event
@@ -85,6 +87,7 @@
reactor.callLater(2, _stop_recording, TEST.ari)
return True
+
def on_recording_finished(ari, event, test_object):
"""Handler for the RecordingFinished
@@ -116,7 +119,7 @@
try:
superfreak = TEST.ari.post('recordings/stored', 'superfly', 'copy',
- destinationRecordingName='copy/superfreak').json()
+ destinationRecordingName='copy/superfreak').json()
except requests.exceptions.HTTPError:
LOGGER.error('Failed to get copied recording superfreak')
fail_test()
@@ -152,4 +155,3 @@
LOGGER.info("Test finished")
test_object.stop_reactor()
return True
-
diff --git a/tests/rest_api/recording/stored/copy/off-nominal/recording.py b/tests/rest_api/recording/stored/copy/off-nominal/recording.py
index 7fc2907..edaba79 100644
--- a/tests/rest_api/recording/stored/copy/off-nominal/recording.py
+++ b/tests/rest_api/recording/stored/copy/off-nominal/recording.py
@@ -13,6 +13,7 @@
LOGGER = logging.getLogger(__name__)
+
class TestLogic(object):
"""A small object used to hold test data between events"""
@@ -58,6 +59,7 @@
LOGGER.info("Baseline recording started successfully.")
return True
+
def on_recording_started(ari, event, test_object):
"""Handler for the RecordingStarted event
@@ -86,6 +88,7 @@
reactor.callLater(2, _stop_recording, TEST.ari)
return True
+
def on_recording_finished(ari, event, test_object):
"""Handler for the RecordingFinished
@@ -108,7 +111,7 @@
try:
superfreak = TEST.ari.post('recordings/stored', 'superfly', 'copy',
- destinationRecordingName='copy/superfreak').json()
+ destinationRecordingName='copy/superfreak').json()
except requests.exceptions.HTTPError:
LOGGER.error('Failed to get copied recording superfreak')
fail_test()
@@ -118,14 +121,14 @@
TEST.ari.set_allow_errors(True)
bad_recording = TEST.ari.post('recordings/stored', 'superfly', 'copy',
- destinationRecordingName='copy/superfreak')
+ destinationRecordingName='copy/superfreak')
if bad_recording.status_code != 409:
LOGGER.error('Expected to get response 409, got %d' % bad_recording.status_code)
fail_test()
return
bad_recording = TEST.ari.post('recordings/stored', 'not-superfly', 'copy',
- destinationRecordingName='copy/super-duper-freak')
+ destinationRecordingName='copy/super-duper-freak')
if bad_recording.status_code != 404:
LOGGER.error('Expected to get response 404, got %d' % bad_recording.status_code)
fail_test()
@@ -154,4 +157,3 @@
LOGGER.info("Test finished")
test_object.stop_reactor()
return True
-
--
To view, visit https://gerrit.asterisk.org/968
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4950056e10d8ffc1fca12fece432a112117aa353
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
More information about the asterisk-code-review
mailing list