# Asterisk Project : CDRModule

Added by mjordan , edited by mjordan on Jul 01, 2012

# Description

CDRModule provides CDR verification for CSV CDR files. Individual CSV records can be verified, specifying as much or as little of a record as needed for the test.

# Class Description

- Module: cdr
- Class: CDRModule

Name | Parameter | Description | Default
--- | --- | --- | ---
_init_ |  | Constructor |
| module_config | The CDRModule configuration, as read from the parsed YAML configuration file |
| test_object | The test object that orchestrates and manages the execution of Asterisk |
match_cdrs |  | Method that can be overriden by classes that derive from CDRModule. By default, each expected record result will be checked in the specified CSV CDR files. If all expected record results are detected, the test_object's passed setting is set to passed. |

# Configuration

The configuration of CDRModule is a sequence that contains one or more nodes consisting of the following key/value pairs.

Keyword | Description | Required | Default
--- | --- | --- | ---
file | The CSV file that these records should reside in | Yes |
lines | The expected CSV records. This sequence of expected entries must be in the same order as they appear in the CSV CDR file |

Each lines entry can contain any of the keywords accepted by a CDR record entry. If a lines entry is not specified, the value is not considered when determining if the actual entry matches the expected entry. Regular expressions may be used in any value to match a range of actual results.

# Example

#### cdr_userfield

    test-modules:
        test-object:
            config-section: test-object-config
            typename: 'SimpleTestCase.SimpleTestCase'
        modules:
            -
                config-section: 'cdr-config'
                typename: 'cdr.CDRModule'

    cdr-config:
        -
            file: 'cdrtest_local'
            lines:
                -
                    source: ''
                    destination: '1'
                    dcontext: 'default'
                    callerid: ''
                    channel: 'Local/1@default-.*'
                    dchannel: ''
                    lastapp: 'Hangup'
                    lastarg: ''
                    disposition: 'ANSWERED'
                    amaflags: 'DOCUMENTATION'
                    userfield: 'bazinga'

#### console_fork_before_dial

In this case, the test uses a class, ForkCdrModule, that derives from CDRModule to perform CDR verification

    test-modules:
        test-object:
            config-section: test-object-config
            typename: 'SimpleTestCase.SimpleTestCase'
        modules:
            -
                load-from-path: 'tests/cdr'
                config-section: 'cdr-config'
                typename: 'ForkCdrModule.ForkCdrModuleBasic'

    cdr-config:
        -
            file: 'cdrtest_local'
            lines:
                -
                    accountcode: 'cdrtest_local'
                    destination: '1'
                    dcontext: 'default'
                    channel: 'Local/1@default-.*'
                    disposition: 'ANSWERED'
                    amaflags: 'DOCUMENTATION'
                -
                    accountcode: 'cdrtest_local'
                    destination: '1'
                    dcontext: 'default'
                    channel: 'Local/1@default-.*'
                    disposition: 'ANSWERED'
                    amaflags: 'DOCUMENTATION'
        -
            file: 'cdrtest_sip'
            lines:
                -
                    accountcode: 'cdrtest_sip'
                    destination: '2'
                    dcontext: 'default'
                    channel: 'SIP/test-.*'
                    disposition: 'ANSWERED'
                    amaflags: 'DOCUMENTATION'