[svn-commits] jpeeler: branch jpeeler/event_watcher r283 - /asterisk/team/jpeeler/event_wat...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed May 5 15:44:39 CDT 2010
Author: jpeeler
Date: Wed May 5 15:44:36 2010
New Revision: 283
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=283
Log:
move and improve documentation
Modified:
asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py
asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test
Modified: asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py?view=diff&rev=283&r1=282&r2=283
==============================================================================
--- asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py (original)
+++ asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py Wed May 5 15:44:36 2010
@@ -12,6 +12,85 @@
except ImportError:
print "Running in standalone mode"
STANDALONE = True
+
+"""
+This module is meant to be instantiated and then the following methods
+run to set up proper operation:
+
+ set_timeout(5)
+ set_test_obj(<Test class instance>)
+
+set_timeout simply sets the number of seconds before a test is considered to
+have timed out.
+
+set_test_obj gives the watcher class the necessary information to call
+each test method. Each test method is defined in a class of your choosing
+similar to below. The purpose of each test method is to set the events to be
+monitored for as well as optionally events to send which also need events
+monitored.
+
+ def test0(self, watcher):
+ event1 = [{'response' : 'Success', 'ping' : 'Pong'}]
+ watcher.add_event(event1)
+ event_send = {'Action' : 'ping'}
+ watcher.add_send_event(event_send)
+
+ # identical test
+ def test1(self, watcher):
+ event1 = [{'response' : 'Success', 'ping' : 'Pong'}]
+ watcher.add_event(event1)
+ event_send = {'Action' : 'ping'}
+ watcher.add_send_event(event_send)
+
+ def test2(self, watcher):
+ event1 = [{'event' : 'Alarm', 'channel' : '17' }]
+ event2 = [{'event' : 'Alarm', 'channel' : '18' }]
+ event3 = [{'event' : 'Alarm', 'channel' : '20' }, {'event' : 'Alarm', 'channel' : '19'}]
+ watcher.add_event(event1)
+ watcher.add_event(event2)
+ watcher.add_event(event3)
+ watcher.set_ordered(True)
+
+ # alternative event set up:
+ #watcher.set_events(False,
+ # [[{'event' : 'Alarm', 'channel' : '18' }],
+ # [{'event' : 'Alarm', 'channel' : '17' }],
+ # [{'event' : 'Alarm', 'channel' : '19' }, {'event' : 'Alarm', 'channel' : '20'}]])
+
+Events are described using dictionaries very similar to how they would appear
+in a manager session. Only the portion of the event you want to match should
+be specified.
+
+Events to monitor are added via add_event. Add_event takes a list of
+dictionaries. The reason it is a list is to cover the case where you want to
+specify either event may be considered as a successful match.
+
+Events to send are added via add_send_event. Add_send_event takes a dictionary
+representing the event to send.
+
+The client module contains a set_ordered method which may either be set True or
+False, depending on whether or not the order of the event matching matters. Or
+the set_events method may be used which the first argument sets the ordering
+method and the second argument is a list of list of dictionaries for all events
+to be matched.
+
+These are the supported event monitoring scenarios:
+
+S1: unordered
+[SEND] -> 3 -> 1 -> 2
+
+S2: ordered
+[SEND] -> 1 -> 2 -> 3
+
+S3: optional events
+[SEND] -> 1 -> {2, 3} -> 4
+
+The [SEND] above is optional and corresponds to the add_send_event method,
+which also takes a dictionary representing the event to be sent.
+
+"""
+
+
class EventWatcher():
Modified: asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test?view=diff&rev=283&r1=282&r2=283
==============================================================================
--- asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test (original)
+++ asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test Wed May 5 15:44:36 2010
@@ -9,37 +9,12 @@
import os, logging, pprint, time, sys
"""
-Some info from author:
This test module should serve as a template for new event monitoring tests. A
test class is created with sequential test methods named testX, where X starts
at 0. The purpose of each test method is to set the events to be monitored for
as well as optionally events to send which also need events monitored.
-Events are described using dictionaries very similar to how they would appear
-in a manager session. Only the portion of the event you want to match should
-be specified.
-
-Events to monitor are added via add_event. Add_event takes a list of
-dictionaries. The reason it is a list is to cover the case where you want to
-specify either event may be considered as a successful match.
-
-Events to send are added via add_send_event. Add_send_event takes a dictionary
-representing the event to send.
-
-The client module contains a set_ordered method which may either be set True or
-False, depending on whether or not the order of the event matching matters.
-
-These are the supported event monitoring scenarios:
-
-S1: unordered
-[SEND] -> 3 -> 1 -> 2
-
-S2: ordered
-[SEND] -> 1 -> 2 ->3
-
-S3: optional events
-[SEND] -> 1 -> {2, 3} -> 4
-
+Please see the documentation in the client module for more information.
"""
class Test():
@@ -50,36 +25,6 @@
event_send = {'Action' : 'ping'}
watcher.add_send_event(event_send)
- #def test1(self, watcher):
- # event1 = [{'response' : 'Success', 'ping' : 'Pong'}]
- # watcher.add_event(event1)
- # event_send = {'Action' : 'ping'}
- # watcher.add_send_event(event_send)
-
- #def test2(self, watcher):
- #scenario 2 with optional event matching
- #event1 = [{'event' : 'Alarm', 'channel' : '18' }]
- #event2 = [{'event' : 'Alarm', 'channel' : '17' }]
- #event3 = [{'event' : 'Alarm', 'channel' : '20' }, {'event' : 'Alarm', 'channel' : '19'}]
- #watcher.add_event(event1)
- #watcher.add_event(event2)
- #watcher.add_event(event3)
- #watcher.set_ordered(True)
-
- #event1 = [{'event' : 'Alarm', 'channel' : '17' }]
- #event2 = [{'event' : 'Alarm', 'channel' : '18' }]
- #event3 = [{'event' : 'Alarm', 'channel' : '20' }, {'event' : 'Alarm', 'channel' : '19'}]
- #watcher.add_event(event1)
- #watcher.add_event(event2)
- #watcher.add_event(event3)
-
- # alternative event set up:
- #watcher.set_events(False,
- # [[{'event' : 'Alarm', 'channel' : '18' }],
- # [{'event' : 'Alarm', 'channel' : '17' }],
- # [{'event' : 'Alarm', 'channel' : '19' }, {'event' : 'Alarm', 'channel' : '20'}]])
- #watcher.set_ordered(True)
-
def main():
logging.basicConfig()
More information about the svn-commits
mailing list