Description
SimpleTestCase is a class that inherits from TestCase and acts as a test object in the pluggable framework. SimpleTestCase has the following characteristics:
- It controls a single instance of Asterisk.
- It can originate n calls into Asterisk in a successive sequence.
- It can determine the success of an originated call either by a UserEvent or by a Hangup event.
- If UserEvents are used, the test is assumed to pass if a configurable number of events are received.
- Pass/failure of the test is can be determined by other modules, or by classes that derive from SimpleTestCase. Classes that derive from SimpleTestCase can override the verify_event method, which is called for each UserEvent received.
Class Description
- Module: SimpleTestCase
- Class: SimpleTestCase : TestCase
Name |
Parameter |
Description |
Default |
---|---|---|---|
_init_ |
|
Constructor |
|
|
test_path |
Optional. Full path to the directory executing the test. If used in the pluggable framework, this value will be populated. |
'' |
|
test_config |
Optional. An object populated with values from the YAML configuration file. If used in the pluggable framework, this value will be populated. |
None |
ami_connect |
|
Called when an AMI connection is made with the instance of Asterisk |
|
|
ami |
The starpy AMI object |
|
hangup |
|
A twisted deferred callback function that is called when all channels have hung up |
|
|
result |
Object passed back from the result of the hangup AMI command |
|
verify_event |
|
Virtual method that can be overriden by a derived class to provide additional logic on reception of a UserEvent. Returning true from this method will cause the SimpleTestCase class to process the next call; false will cause the test to fail. |
|
|
event |
The UserEvent object |
|
run |
|
Override of TestCase.run. Creates the AMI factory. |
|
Configuration
Keyword |
Description |
Required |
Default |
---|---|---|---|
expected-events |
The expected number of UserEvents that should be received. |
No |
1 |
spawn-after-hangup |
If true, Hangup events will cause the next call in the sequence to be originated. Otherwise, reception of UserEvents will trigger the next call in the sequence. Note that it is expected that if UserEvents are present, this value should be false. |
No |
False |
ignore-originate-failures |
Do not report an error if an originate fails. |
No |
False |
test-iterations |
A sequence of items that specify calls to originate. |
No |
|
test-iterations
Keyword |
Description |
Required |
Default |
---|---|---|---|
channel |
The channel to originate |
Yes |
|
application |
The application to connect to |
*See Note |
|
context |
The context in the dialplan to connect the originated call to |
*See Note |
|
extension |
The extension in the dialplan to connect the originated call to |
*See Note |
|
priority |
The priority in the dialplan to connect the originated call to |
*See Note |
|
Examples
cdr_accountcode
test-modules: test-object: config-section: test-object-config typename: 'SimpleTestCase.SimpleTestCase' test-object-config: spawn-after-hangup: True test-iterations: - channel: 'Local/1@default' application: 'Echo'
batch_cdrs
test-modules: test-object: config-section: test-object-config typename: 'SimpleTestCase.SimpleTestCase' test-object-config: spawn-after-hangup: True ignore-originate-failures: True test-iterations: - channel: 'Local/dial_busy@default' application: 'Echo' - channel: 'Local/dial_busy@default' application: 'Echo' - channel: 'Local/dial_answer@default' application: 'Echo' - channel: 'Local/dial_answer@default' application: 'Echo'