<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/testsuite/+/16566">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; Verified
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">lib/python: asterisk.opensslversion support Python 3.<br><br>Add support to comparing version of opensslversion module in the<br>for Python 3 and adds self_test.<br><br>ASTERISK_26826<br><br>Change-Id: Ic66d845cc5e3375a0d556709bdf6d17cfea0016e<br>---<br>M lib/python/asterisk/opensslversion.py<br>A lib/python/asterisk/self_test/test_opensslversion.py<br>M lib/python/asterisk/test_config.py<br>3 files changed, 48 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/lib/python/asterisk/opensslversion.py b/lib/python/asterisk/opensslversion.py</span><br><span>index 3fa5cd5..e82d84b 100644</span><br><span>--- a/lib/python/asterisk/opensslversion.py</span><br><span>+++ b/lib/python/asterisk/opensslversion.py</span><br><span>@@ -44,8 +44,16 @@</span><br><span> return self.version</span><br><span> </span><br><span> def __cmp__(self, other):</span><br><span style="color: hsl(0, 100%, 40%);">- """Compare two SIPpVersion instances against each other"""</span><br><span style="color: hsl(0, 100%, 40%);">- return cmp(self.version, other.version)</span><br><span style="color: hsl(120, 100%, 40%);">+ """Compare two OpenSSLVersion instances against each other"""</span><br><span style="color: hsl(120, 100%, 40%);">+ return (int(self.version) > int(other.version)) - (int(self.version) < int(other.version))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ def __le__(self, other):</span><br><span style="color: hsl(120, 100%, 40%);">+ """Determine if this OpenSSLVersion instance is less than or equal to another"""</span><br><span style="color: hsl(120, 100%, 40%);">+ return int(self.version) <= int(other.version)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ def __lt__(self, other):</span><br><span style="color: hsl(120, 100%, 40%);">+ """Determine if this OpenSSLVersion instance is less than another"""</span><br><span style="color: hsl(120, 100%, 40%);">+ return int(self.version) < int(other.version)</span><br><span> </span><br><span> def __ne__(self, other):</span><br><span> return self.version != other.version</span><br><span>diff --git a/lib/python/asterisk/self_test/test_opensslversion.py b/lib/python/asterisk/self_test/test_opensslversion.py</span><br><span>new file mode 100755</span><br><span>index 0000000..a00598f</span><br><span>--- /dev/null</span><br><span>+++ b/lib/python/asterisk/self_test/test_opensslversion.py</span><br><span>@@ -0,0 +1,37 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/usr/bin/env python</span><br><span style="color: hsl(120, 100%, 40%);">+"""OpenSSLVersion String Handling Tests</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Rodrigo Ramirez Norambuena <a@rodrigoramirez.com></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+This program is free software, distributed under the terms of</span><br><span style="color: hsl(120, 100%, 40%);">+the GNU General Public License Version 2.</span><br><span style="color: hsl(120, 100%, 40%);">+"""</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+from harness_shared import main</span><br><span style="color: hsl(120, 100%, 40%);">+import unittest</span><br><span style="color: hsl(120, 100%, 40%);">+from asterisk.opensslversion import OpenSSLVersion</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+class OpenSSLVersionTests(unittest.TestCase):</span><br><span style="color: hsl(120, 100%, 40%);">+ def test_cmp_greater_than(self):</span><br><span style="color: hsl(120, 100%, 40%);">+ v1 = OpenSSLVersion("1.0.1", None)</span><br><span style="color: hsl(120, 100%, 40%);">+ v2 = OpenSSLVersion("1.0.0", None)</span><br><span style="color: hsl(120, 100%, 40%);">+ self.assertTrue(v1 > v2)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ def test_cmp_less_than(self):</span><br><span style="color: hsl(120, 100%, 40%);">+ v1 = OpenSSLVersion("1.0.1", None)</span><br><span style="color: hsl(120, 100%, 40%);">+ v2 = OpenSSLVersion("1.0.0", None)</span><br><span style="color: hsl(120, 100%, 40%);">+ self.assertTrue(v2 < v1)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ def test_cmp_equal(self):</span><br><span style="color: hsl(120, 100%, 40%);">+ v1 = OpenSSLVersion("1.0.0", None)</span><br><span style="color: hsl(120, 100%, 40%);">+ v2 = OpenSSLVersion("1.0.0", None)</span><br><span style="color: hsl(120, 100%, 40%);">+ self.assertTrue(v1 == v2)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ def test_cmp_not_equal(self):</span><br><span style="color: hsl(120, 100%, 40%);">+ v1 = OpenSSLVersion("1.0.1", None)</span><br><span style="color: hsl(120, 100%, 40%);">+ v2 = OpenSSLVersion("1.0.0", None)</span><br><span style="color: hsl(120, 100%, 40%);">+ self.assertTrue(v1 != v2)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+if __name__ == "__main__":</span><br><span style="color: hsl(120, 100%, 40%);">+ main()</span><br><span>diff --git a/lib/python/asterisk/test_config.py b/lib/python/asterisk/test_config.py</span><br><span>index 64d8ffb..f4dc99f 100644</span><br><span>--- a/lib/python/asterisk/test_config.py</span><br><span>+++ b/lib/python/asterisk/test_config.py</span><br><span>@@ -165,7 +165,7 @@</span><br><span> self.met = True</span><br><span> elif "pcap" in dep:</span><br><span> self.name = "pcap"</span><br><span style="color: hsl(0, 100%, 40%);">- from test_case import PCAP_AVAILABLE</span><br><span style="color: hsl(120, 100%, 40%);">+ from .test_case import PCAP_AVAILABLE</span><br><span> self.met = PCAP_AVAILABLE</span><br><span> else:</span><br><span> print("Unknown dependency type specified:")</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/testsuite/+/16566">change 16566</a>. To unsubscribe, or for help writing mail filters, 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/c/testsuite/+/16566"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ic66d845cc5e3375a0d556709bdf6d17cfea0016e </div>
<div style="display:none"> Gerrit-Change-Number: 16566 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: Rodrigo Ramirez Norambuena <a@rodrigoramirez.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>