[Zodb-checkins] CVS: Packages/ZConfig/tests - test_datatypes.py:1.1.2.2

Fred L. Drake, Jr. fred@zope.com
Fri, 20 Dec 2002 12:38:25 -0500


Update of /cvs-repository/Packages/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv28909

Modified Files:
      Tag: zconfig-schema-devel-branch
	test_datatypes.py 
Log Message:
Added tests for the new conversions inet-address, socket-address


=== Packages/ZConfig/tests/test_datatypes.py 1.1.2.1 => 1.1.2.2 ===
--- Packages/ZConfig/tests/test_datatypes.py:1.1.2.1	Fri Dec 20 12:08:13 2002
+++ Packages/ZConfig/tests/test_datatypes.py	Fri Dec 20 12:38:24 2002
@@ -72,6 +72,14 @@
         raises(ValueError, convert, "-123")
         raises(ValueError, convert, "")
 
+    def test_datatype_inet_address(self):
+        convert = self.types.get("inet-address")
+        eq = self.assertEqual
+        eq(convert("Host.Example.Com:80"), ("host.example.com", 80))
+        eq(convert(":80"),                 ("", 80))
+        eq(convert("80"),                  ("", 80))
+        eq(convert("host.EXAMPLE.com"),    ("host.example.com", None))
+
     def test_datatype_integer(self):
         convert = self.types.get("integer")
         eq = self.assertEqual
@@ -117,6 +125,16 @@
         eq(convert('60000'), 60000)
         eq(convert('65535'), 0xffff)
         raises(ValueError, convert, '65536')
+
+    def test_datatype_socket_address(self):
+        convert = self.types.get("socket-address")
+        eq = self.assertEqual
+        eq(convert("Host.Example.Com:80"),(AF_INET, ("host.example.com", 80)))
+        eq(convert(":80"),                (AF_INET, ("", 80)))
+        eq(convert("80"),                 (AF_INET, ("", 80)))
+        eq(convert("host.EXAMPLE.com"),   (AF_INET, ("host.example.com",None)))
+        eq(convert("/tmp/var/@345.4"),    (AF_UNIX, "/tmp/var/@345.4"))
+        eq(convert("/tmp/var/@345.4:80"), (AF_UNIX, "/tmp/var/@345.4:80"))
 
 
 def test_suite():