<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/9280">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">matcher.py: Always check final conditions<br><br>The matcher functionality was checking the final conditions only if the test<br>was marked as passed. Since the initial default value for the test_case<br>variable is 'None' this could cause the test to fail, but without error messages<br>output.<br><br>This patch makes it so the final condtions in matcher are always checked when<br>the test ends. Also if all final conditions pass then the test object is set<br>to passing (passed=true). Lastly the error message output was updated to make<br>it a little more readable.<br><br>Change-Id: Ibdd3041e8fb023b9396d80ec766ade934e50bcaa<br>---<br>M lib/python/asterisk/matcher.py<br>M lib/python/asterisk/self_test/test2_matcher.py<br>2 files changed, 17 insertions(+), 22 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/lib/python/asterisk/matcher.py b/lib/python/asterisk/matcher.py<br>index 87c62be..3ab9c24 100644<br>--- a/lib/python/asterisk/matcher.py<br>+++ b/lib/python/asterisk/matcher.py<br>@@ -128,9 +128,13 @@<br>     def error(self):<br>         """Error out the conditional."""<br> <br>-        return ("\nCondition: '{0}'\nExpected >= {1} and <= {2} but "<br>-                "received {3}".format(self.pattern, self.minimum,<br>-                                      self.maximum, self.count))<br>+        if self.minimum == self.maximum:<br>+            expected = "{0}".format(self.minimum)<br>+        else:<br>+            expected = ">= {0} and <= {1}".format(self.minimum, self.maximum)<br>+<br>+        return ("\nCondition: '{0}'\nExpected {1} but received {2}".format(<br>+            self.pattern, expected, self.count))<br> <br> <br> class Conditions(object):<br>@@ -272,13 +276,14 @@<br>             return self.conditions.check(value)<br>         except ConditionError as e:<br>             self.fail_and_stop(e)<br>+        return False<br> <br>     def check_final(self):<br>-        if self.test_object.passed:<br>-            try:<br>-                self.conditions.check_final()<br>-            except ConditionError as e:<br>-                self.fail_and_stop(e)<br>+        try:<br>+            self.test_object.set_passed(self.conditions.check_final())<br>+        except ConditionError as e:<br>+            self.fail_and_stop(e)<br>+<br>         return self.test_object.passed<br> <br>     def __handle_stop(self, *args):<br>diff --git a/lib/python/asterisk/self_test/test2_matcher.py b/lib/python/asterisk/self_test/test2_matcher.py<br>index 0357ce9..b132353 100755<br>--- a/lib/python/asterisk/self_test/test2_matcher.py<br>+++ b/lib/python/asterisk/self_test/test2_matcher.py<br>@@ -110,18 +110,16 @@<br>         self.assertFalse(conditions.check_final())<br> <br>         # Check with one message handled<br>-        self.test_object.set_passed(True)<br>         self.assertFalse(conditions.check('hello'))<br>         self.assertFalse(conditions.check_final())<br> <br>         # Check with two messages handled<br>-        self.test_object.set_passed(True)<br>         self.assertTrue(conditions.check('hello'))<br>         self.assertTrue(conditions.check_final())<br> <br>         # Check with three messages handled<br>         self.assertFalse(conditions.check('hello'))<br>-        self.assertFalse(conditions.check_final())<br>+        self.assertTrue(conditions.check_final())  # min met<br> <br>     def test_005_count(self):<br>         """Test range count condition"""<br>@@ -138,12 +136,10 @@<br>         self.assertFalse(conditions.check_final())<br> <br>         # Check with one message handled<br>-        self.test_object.set_passed(True)<br>         self.assertFalse(conditions.check('hello'))<br>         self.assertFalse(conditions.check_final())<br> <br>         # Check with two messages handled<br>-        self.test_object.set_passed(True)<br>         self.assertTrue(conditions.check('hello'))<br>         self.assertTrue(conditions.check_final())<br> <br>@@ -154,7 +150,7 @@<br> <br>         # Check with five messages handled<br>         self.assertFalse(conditions.check('hello'))<br>-        self.assertFalse(conditions.check_final())<br>+        self.assertTrue(conditions.check_final())  # min met<br> <br>     def test_006_min(self):<br>         """Test minimum condition"""<br>@@ -171,12 +167,10 @@<br>         self.assertFalse(conditions.check_final())<br> <br>         # Check with one message handled<br>-        self.test_object.set_passed(True)<br>         self.assertFalse(conditions.check('hello'))<br>         self.assertFalse(conditions.check_final())<br> <br>         # Check with two messages handled<br>-        self.test_object.set_passed(True)<br>         self.assertTrue(conditions.check('hello'))<br>         self.assertTrue(conditions.check_final())<br> <br>@@ -200,7 +194,7 @@<br> <br>         # Check with two messages handled<br>         self.assertFalse(conditions.check('hello'))<br>-        self.assertFalse(conditions.check_final())<br>+        self.assertTrue(conditions.check_final())  # min met<br> <br>     def test_008_max(self):<br>         """Test no match condition"""<br>@@ -218,7 +212,7 @@<br> <br>         # Check with one message handled<br>         self.assertFalse(conditions.check('hello'))<br>-        self.assertFalse(conditions.check_final())<br>+        self.assertTrue(conditions.check_final())  # min met<br> <br>     def test_009_trigger_on_any(self):<br>         """Test trigger on any option"""<br>@@ -236,7 +230,6 @@<br>         self.assertFalse(conditions.check('world'))<br>         self.assertFalse(conditions.check_final())<br> <br>-        self.test_object.set_passed(True)<br>         self.assertTrue(conditions.check('hello'))  # 'hello' is met<br>         self.assertFalse(conditions.check_final())  # 'world' not me<br> <br>@@ -245,7 +238,6 @@<br>         self.assertFalse(conditions.check('world'))<br>         self.assertFalse(conditions.check_final())<br> <br>-        self.test_object.set_passed(True)<br>         self.assertTrue(conditions.check('world'))  # 'world' is met<br>         self.assertFalse(conditions.check_final())  # 'hello' not met<br> <br>@@ -265,11 +257,9 @@<br>         self.assertFalse(conditions.check('world'))<br>         self.assertFalse(conditions.check_final())<br> <br>-        self.test_object.set_passed(True)<br>         self.assertFalse(conditions.check('hello'))  # 'world' not met<br>         self.assertFalse(conditions.check_final())<br> <br>-        self.test_object.set_passed(True)<br>         self.assertTrue(conditions.check('world'))<br>         self.assertTrue(conditions.check_final())<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9280">change 9280</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/9280"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ibdd3041e8fb023b9396d80ec766ade934e50bcaa </div>
<div style="display:none"> Gerrit-Change-Number: 9280 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>