<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/1552/">https://reviewboard.asterisk.org/r/1552/</a>
</td>
</tr>
</table>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/1552/diff/4/?file=21618#file21618line55" style="color: black; font-weight: bold; text-decoration: underline;">/asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py</a>
<span style="font-weight: normal;">
(Diff revision 4)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">def main():</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">53</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="bp">self</span><span class="o">.</span><span class="n">CDRFileExpectations</span> <span class="o">=</span> <span class="p">[]</span></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I'm not entirely sure this is the best data structure for the job. I'm assuming you need to store multiple CDR files and their records together. Based on how you store the data, it looks like you really would do better with a dictionary of lists. The key is the filename, and you just append to the list. So you have:
self.CDRFileExpectations[filename].append(cdrline)
You'll have to do a bit of checking the first time you append, although with python, I don't think its much.</pre>
</div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/1552/diff/4/?file=21618#file21618line89" style="color: black; font-weight: bold; text-decoration: underline;">/asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py</a>
<span style="font-weight: normal;">
(Diff revision 4)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">def main():</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">78</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="k">for</span> <span class="n">count</span><span class="p">,</span> <span class="n">cdrline</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CDRLineExpectations</span><span class="p">):</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">87</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="nb">len</span><span class="p">(</span><span class="n">i</span><span class="p">)):</span></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I actually find the original way of doing this easier to understand. Again, if you just need want to associate multiple CDR records (and their lines) into a single object, a dictionary of lists would be more straightforward in python.</pre>
</div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/1552/diff/4/?file=21618#file21618line101" style="color: black; font-weight: bold; text-decoration: underline;">/asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py</a>
<span style="font-weight: normal;">
(Diff revision 4)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">def main():</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">96</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s">.csv - CDR results did not meet expectations. Test Failed."</span> <span class="o">%</span> <span class="n">i</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Don't use debug for this - you won't see it in most test runs, which means you have to go digging through 10000 lines of debug to find that your test did indeed fail. Make it at least a WARNING.</pre>
</div>
<br />
<p>- mjordan</p>
<br />
<p>On November 4th, 2011, 8:56 a.m., jrose wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers, Paul Belanger and mjordan.</div>
<div>By jrose.</div>
<p style="color: grey;"><i>Updated Nov. 4, 2011, 8:56 a.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">A while back, Pabelanger and I were working on creating a general method of testing CDR logging. At the time, we sort of hit a wall with the order individual call logs were being stuffed into the master cdr file.
In order to alleviate that, this patch changes the CDRTestCase class to use CDR files generated based on account codes. At the moment, I'm just specifically using a testsuite account code and loading that cdr file, but it isn't a stretch to say we could put in multiple account codes and use a bunch of different cdr logs so that the order of which channel hangs up isn't important.
In addition to that, a couple minor changes were made to the cdr_originate_sip_congestion_log test. It now runs without any chance for timing based failures (before it was 50/50 whether congestion or failure would come first/second, now only one action is checked and logged, that being the congestion).
If this seems appropriate, I'll move forward with making the CDR Expectations use a variable to determine which file they should be checking against.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Checked to see how the test was logging CDR in separate files, made sure test was passing appropriately.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/manager.general.conf.inc <span style="color: grey">(2675)</span></li>
<li>/asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/sip.conf <span style="color: grey">(2675)</span></li>
<li>/asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/run-test <span style="color: grey">(2675)</span></li>
<li>/asterisk/team/group/cdr_test_log_congestion/tests/cdr/cdr_originate_sip_congestion_log/configs/ast1/extensions.conf <span style="color: grey">(2675)</span></li>
<li>/asterisk/team/group/cdr_test_log_congestion/lib/python/asterisk/CDRTestCase.py <span style="color: grey">(2675)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1552/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>