<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2172/18/9/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/CDRModule">CDRModule</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://wiki.asterisk.org/wiki/display/~mjordan">Matt Jordan</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h1><a name="CDRModule-Description"></a>Description</h1>

<p>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.</p>

<h1><a name="CDRModule-ClassDescription"></a>Class Description</h1>

<ul>
        <li><b>Module:</b> cdr</li>
        <li><b>Class:</b> CDRModule</li>
</ul>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Name</th>
<th class='confluenceTh'>Parameter</th>
<th class='confluenceTh'>Description</th>
<th class='confluenceTh'>Default</th>
</tr>
<tr>
<td class='confluenceTd'>_<em>init</em>_</td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>Constructor</td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>module_config</td>
<td class='confluenceTd'>The CDRModule configuration, as read from the parsed YAML configuration file </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>test_object</td>
<td class='confluenceTd'>The test object that orchestrates and manages the execution of Asterisk </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'>match_cdrs</td>
<td class='confluenceTd'> 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. </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
</tbody></table>
</div>


<h1><a name="CDRModule-Configuration"></a>Configuration</h1>

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

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Keyword</th>
<th class='confluenceTh'>Description</th>
<th class='confluenceTh'>Required</th>
<th class='confluenceTh'>Default</th>
</tr>
<tr>
<td class='confluenceTd'> file </td>
<td class='confluenceTd'> The CSV file that these records should reside in </td>
<td class='confluenceTd'> Yes </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> lines </td>
<td class='confluenceTd'> The expected CSV records.  This sequence of expected entries must be in the same order as they appear in the CSV CDR file </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
</tbody></table>
</div>


<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>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.</td></tr></table></div>

<h1><a name="CDRModule-Example"></a>Example</h1>

<h4><a name="CDRModule-cdruserfield"></a>cdr_userfield</h4>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">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'</pre>
</div></div>

<h4><a name="CDRModule-consoleforkbeforedial"></a>console_fork_before_dial</h4>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>In this case, the test uses a class, ForkCdrModule, that derives from CDRModule to perform CDR verification</td></tr></table></div>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">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'</pre>
</div></div>
    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
       <a href="https://wiki.asterisk.org/wiki/display/AST/CDRModule">View Online</a>
              |
       <a href="https://wiki.asterisk.org/wiki/display/AST/CDRModule?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>