[asterisk-commits] pabelanger: branch pabelanger/sipp r1095 - /asterisk/team/pabelanger/sipp/lib...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 7 11:47:14 CST 2010


Author: pabelanger
Date: Tue Dec  7 11:47:10 2010
New Revision: 1095

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1095
Log:
More unit tests.

Added:
    asterisk/team/pabelanger/sipp/lib/python/sipp/__init__.py   (with props)
Modified:
    asterisk/team/pabelanger/sipp/lib/python/sipp/version.py

Added: asterisk/team/pabelanger/sipp/lib/python/sipp/__init__.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/sipp/lib/python/sipp/__init__.py?view=auto&rev=1095
==============================================================================
    (empty)

Propchange: asterisk/team/pabelanger/sipp/lib/python/sipp/__init__.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/pabelanger/sipp/lib/python/sipp/__init__.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/pabelanger/sipp/lib/python/sipp/__init__.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/team/pabelanger/sipp/lib/python/sipp/version.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/sipp/lib/python/sipp/version.py?view=diff&rev=1095&r1=1094&r2=1095
==============================================================================
--- asterisk/team/pabelanger/sipp/lib/python/sipp/version.py (original)
+++ asterisk/team/pabelanger/sipp/lib/python/sipp/version.py Tue Dec  7 11:47:10 2010
@@ -8,9 +8,13 @@
 the GNU General Public License Version 2.
 """
 
+import re
+import subprocess
 import sys
-import re
 import unittest
+sys.path.append("lib/python")
+
+from asterisk import utils
 
 class SIPpVersion:
     """A SIPp Version.
@@ -18,11 +22,28 @@
     """
 
     def __init__(self, version=None):
-        """Constructor
-
+        """Construct a SIPp Version parser.
+
+        Keyword Arguments:
+        version -- The SIPp version string to parse.
         """
         if version is not None:
             self.version_str = version
+        else:
+            cmd = [
+                utils.which("sipp"), "-v"
+            ]
+            try:
+                p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+                        stderr=subprocess.STDOUT)
+            except OSError:
+                return
+            #XXX TODO: Improve logic
+            for line in p.stdout:
+                if line.strip().startswith('SIPp'):
+                    x = line.strip().lstrip('SIPp ')
+                    x = x.split(',', 1)
+                    self.version_str = x[0]
 
         if not self.version_str:
             return
@@ -36,9 +57,13 @@
         if self.svn is True:
             return -1
         else:
-            res = int(self.concept) * 10000000 + int(self.major) * 100000
+            concept = self.concept.strip('v')
+            res = int(concept) * 10000000 + int(self.major) * 100000
             if self.minor is not None:
                 res += int(self.minor) * 1000
+
+            if self.tls is True and self.pcap is True:
+                res += 1000000000
             return res
 
     def __cmp__(self, other):
@@ -123,24 +148,74 @@
         self.assertTrue(v.pcap)
 
     def test_cmp(self):
-        v1 = SIPpVersion("3.2")
-        v2 = SIPpVersion("3.1")
+        v1 = SIPpVersion("v3.2")
+        v2 = SIPpVersion("v3.1")
         self.assertTrue(v1 > v2)
 
     def test_cmp2(self):
-        v1 = SIPpVersion("2.0.1")
-        v2 = SIPpVersion("3.1")
+        v1 = SIPpVersion("v2.0.1")
+        v2 = SIPpVersion("v3.1")
         self.assertTrue(v1 < v2)
 
     def test_cmp3(self):
-        v1 = SIPpVersion("3.1")
-        v2 = SIPpVersion("3.1")
+        v1 = SIPpVersion("v3.1")
+        v2 = SIPpVersion("v3.1")
         self.assertTrue(v1 == v2)
 
     def test_cmp4(self):
-        v1 = SIPpVersion("2.0.1")
-        v2 = SIPpVersion("2.0.1")
+        v1 = SIPpVersion("v3.1-TLS")
+        v2 = SIPpVersion("v3.1-TLS")
         self.assertTrue(v1 == v2)
+
+    def test_cmp5(self):
+        v1 = SIPpVersion("v2.0.1")
+        v2 = SIPpVersion("v2.0.1")
+        self.assertTrue(v1 == v2)
+
+    def test_cmp6(self):
+        v1 = SIPpVersion("v3.2-TLS-PCAP")
+        v2 = SIPpVersion("v3.2-TLS")
+        self.assertTrue(v1 > v2)
+
+    def test_cmp7(self):
+        v1 = SIPpVersion("v3.2-TLS-PCAP")
+        v2 = SIPpVersion("v3.2-TLS")
+        self.assertFalse(v1 == v2)
+
+    def test_cmp8(self):
+        v1 = SIPpVersion("v3.2-TLS-PCAP")
+        v2 = SIPpVersion("v3.2-PCAP")
+        self.assertTrue(v1 >= v2)
+
+    def test_cmp9(self):
+        v1 = SIPpVersion("v3.2-TLS-PCAP")
+        v2 = SIPpVersion("v2.0.1-PCAP")
+        self.assertTrue(v1 > v2)
+
+    def test_cmp10(self):
+        v1 = SIPpVersion("v3.1-TLS")
+        v2 = SIPpVersion("v3.1-PCAP")
+        self.assertFalse(v1 > v2)
+
+    def test_cmp11(self):
+        v1 = SIPpVersion("v3.1-TLS")
+        v2 = SIPpVersion("v3.1-PCAP")
+        self.assertFalse(v1 < v2)
+
+    def test_cmp12(self):
+        v1 = SIPpVersion("v3.2-TLS")
+        v2 = SIPpVersion("v2.0.1-TLS-PCAP")
+        self.assertFalse(v1 > v2)
+
+    def test_cmp13(self):
+        v1 = SIPpVersion("v3.2-TLS")
+        v2 = SIPpVersion("v3.1-TLS-PCAP")
+        self.assertFalse(v1 > v2)
+
+    def test_cmp14(self):
+        v1 = SIPpVersion("v3.2-TLS")
+        v2 = SIPpVersion("v3.1-TLS-PCAP")
+        self.assertFalse(v1 < v2)
 
 def main():
     unittest.main()




More information about the asterisk-commits mailing list