incubator-heraldry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ket...@apache.org
Subject svn commit: r493328 - in /incubator/heraldry/libraries/python/openid/trunk/openid/test: ./ data/ data/test_etxrd/
Date Sat, 06 Jan 2007 05:21:37 GMT
Author: keturn
Date: Fri Jan  5 21:21:36 2007
New Revision: 493328

URL: http://svn.apache.org/viewvc?view=rev&rev=493328
Log:
[python-to-heraldry @ Refactored test_xrds]
* Moved the data files into a directory just for this test module
 * Made the CanonicalID tests run independently of each other
 * Added a convenience function for locating the data files

No functional changes (intended!)

Original author: Josh Hoyt <josh@janrain.com>
Date: 2006-12-19 21:55:21+00:00

Added:
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/README
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/README
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/delegated-20060809-r1.xrds
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/delegated-20060809-r1.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/delegated-20060809-r2.xrds
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/delegated-20060809-r2.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/delegated-20060809.xrds
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/delegated-20060809.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/no-xrd.xml
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/no-xrd.xml
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/not-xrds.xml
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/not-xrds.xml
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/prefixsometimes.xrds
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/prefixsometimes.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/ref.xrds
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/ref.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/sometimesprefix.xrds
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/sometimesprefix.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/spoof1.xrds
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/spoof1.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/spoof2.xrds
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/spoof2.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/spoof3.xrds
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/spoof3.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/status222.xrds
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/status222.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test_etxrd/valid-populated-xrds.xml
      - copied unchanged from r493327, incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test1-xrd.xml
Removed:
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/README
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/delegated-20060809-r1.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/delegated-20060809-r2.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/delegated-20060809.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/no-xrd.xml
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/not-xrds.xml
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/prefixsometimes.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/ref.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/sometimesprefix.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/spoof1.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/spoof2.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/spoof3.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/status222.xrds
    incubator/heraldry/libraries/python/openid/trunk/openid/test/data/test1-xrd.xml
Modified:
    incubator/heraldry/libraries/python/openid/trunk/openid/test/test_etxrd.py

Modified: incubator/heraldry/libraries/python/openid/trunk/openid/test/test_etxrd.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/python/openid/trunk/openid/test/test_etxrd.py?view=diff&rev=493328&r1=493327&r2=493328
==============================================================================
--- incubator/heraldry/libraries/python/openid/trunk/openid/test/test_etxrd.py (original)
+++ incubator/heraldry/libraries/python/openid/trunk/openid/test/test_etxrd.py Fri Jan  5
21:21:36 2007
@@ -10,10 +10,12 @@
         p = os.path.abspath(p)
     return p
 
+def datapath(filename):
+    return sibpath(__file__, os.path.join("data", "test_etxrd", filename))
 
-XRD_FILE = sibpath(__file__, os.path.join("data", "test1-xrd.xml"))
-NOXRDS_FILE = sibpath(__file__, os.path.join("data", "not-xrds.xml"))
-NOXRD_FILE = sibpath(__file__, os.path.join("data", "no-xrd.xml"))
+XRD_FILE =  datapath('valid-populated-xrds.xml')
+NOXRDS_FILE = datapath('not-xrds.xml')
+NOXRD_FILE = datapath('no-xrd.xml')
 
 # None of the namespaces or service URIs below are official (or even
 # sanctioned by the owners of that piece of URL-space)
@@ -129,37 +131,55 @@
 
 class TestCanonicalID(unittest.TestCase):
 
-    canonicalIDtests = [
-        ("@ootao*test1", "delegated-20060809.xrds",
-         "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"),
-        ("@ootao*test1", "delegated-20060809-r1.xrds",
-         "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"),
-        ("@ootao*test1", "delegated-20060809-r2.xrds",
-         "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"),
-        ("@ootao*test1", "sometimesprefix.xrds",
-         "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"),
-        ("@ootao*test1", "prefixsometimes.xrds",
-         "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"),
-        ("=keturn*isDrummond", "spoof1.xrds", etxrd.XRDSFraud),
-        ("=keturn*isDrummond", "spoof2.xrds", etxrd.XRDSFraud),
-        ("@keturn*is*drummond", "spoof3.xrds", etxrd.XRDSFraud),
-        ("=x", "status222.xrds", None),
-        # Don't let IRI authorities be canonical for the GCS.
-        ("phreak.example.com", "delegated-20060809-r2.xrds", etxrd.XRDSFraud),
-        # TODO: Refs
-        # ("@ootao*test.ref", "ref.xrds", "@!BAE.A650.823B.2475")
-        ]
+    def mkTest(iname, filename, expectedID):
+        """This function builds a method that runs the CanonicalID
+        test for the given set of inputs"""
 
-    # TODO: Add a IRI authority with an IRI canonicalID.
-    # TODO: Add test cases with real examples of multiple CanonicalIDs
-    #   somewhere in the resolution chain.
-
-    def test_getCanonicalID(self):
-        for iname, filename, expectedID in self.canonicalIDtests:
-            filename = sibpath(__file__, os.path.join("data", filename))
+        filename = datapath(filename)
+        def test(self):
             xrds = etxrd.parseXRDS(file(filename).read())
             self._getCanonicalID(iname, xrds, expectedID)
+        return test
+
+    test_delegated = mkTest(
+        "@ootao*test1", "delegated-20060809.xrds",
+        "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01")
+
+    test_delegated_r1 = mkTest(
+        "@ootao*test1", "delegated-20060809-r1.xrds",
+        "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01")
+
+    test_delegated_r2 = mkTest(
+        "@ootao*test1", "delegated-20060809-r2.xrds",
+        "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01")
+
+    test_sometimesprefix = mkTest(
+        "@ootao*test1", "sometimesprefix.xrds",
+        "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01")
+
+    test_prefixsometimes = mkTest(
+        "@ootao*test1", "prefixsometimes.xrds",
+        "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01")
 
+    test_spoof1 = mkTest("=keturn*isDrummond", "spoof1.xrds", etxrd.XRDSFraud)
+
+    test_spoof2 = mkTest("=keturn*isDrummond", "spoof2.xrds", etxrd.XRDSFraud)
+
+    test_spoof3 = mkTest("@keturn*is*drummond", "spoof3.xrds", etxrd.XRDSFraud)
+
+    test_status222 = mkTest("=x", "status222.xrds", None)
+
+    test_iri_auth_not_allowed = mkTest(
+        "phreak.example.com", "delegated-20060809-r2.xrds", etxrd.XRDSFraud)
+    test_iri_auth_not_allowed.__doc__ = \
+        "Don't let IRI authorities be canonical for the GCS."
+
+    # TODO: Refs
+    # test_ref = mkTest("@ootao*test.ref", "ref.xrds", "@!BAE.A650.823B.2475")
+
+    # TODO: Add a IRI authority with an IRI canonicalID.
+    # TODO: Add test cases with real examples of multiple CanonicalIDs
+    #   somewhere in the resolution chain.
 
     def _getCanonicalID(self, iname, xrds, expectedID):
         if isinstance(expectedID, (str, unicode, type(None))):



Mime
View raw message