Пример #1
0
 def test_getMappedURI(self):
     mappingdata_for_mappedPaths = {
         "": {
             "file:///tmp/file1.txt":        "file:///tmp/file1.txt",
             "http://server/tmp/file2.txt":  "http://server/tmp/file2.txt",
             "file:///f.c":                  "file:///f.c",
             "sftp://remote/tmp/file3.txt":  "sftp://remote/tmp/file3.txt",
             "C:\\tmp\\file4.txt":           "C:\\tmp\\file4.txt",
             },
         "http://server/tmp##/tmp::"\
         "sftp://remote##/remote": {
             "file:///tmp/file1.txt":        "file:///tmp/file1.txt",
             "http://server/tmp/file2.txt":  "file:///tmp/file2.txt",
             "file:///f.c":                  "file:///f.c",
             "sftp://remote/tmp/file3.txt":  "file:///remote/tmp/file3.txt",
             "C:\\tmp\\file4.txt":           "C:\\tmp\\file4.txt",
             },
     }
     for mappedPath, mappingData in mappingdata_for_mappedPaths.items():
         prefs = _dummyPrefsClass({"mappedPaths": mappedPath})
         for uri, expected_uri in mappingData.items():
             mapped_uri = uriparse.getMappedURI(uri, prefs)
             self.failUnlessEqual(mapped_uri, expected_uri,
                                  "Mapped URI was not expected: %r != %r" %
                                  (mapped_uri, expected_uri))
Пример #2
0
 def test_URIUnmapping(self):
     # Testcase to show where the current mapped uri system falls down
     mappingdata_for_mappedPaths = {
         "": {
             "file://myserver/tmp/file1.txt":  "file://myserver/tmp/file1.txt",
         },
         "file://myserver/tmp##file://C:/tmp": {
             "file://myserver/tmp/file1.txt":  "file:///C:/tmp/file1.txt",
         },
         "file://myserver/tmp##C:\\tmp": {
             "file://myserver/tmp/file1.txt":  "file:///C:/tmp/file1.txt",
         },
     }
     for mappedPath, mappingData in mappingdata_for_mappedPaths.items():
         prefs = _dummyPrefsClass({"mappedPaths": mappedPath})
         for path, expected_uri in mappingData.items():
             mapped_uri = uriparse.getMappedURI(path, prefs)
             self.failUnlessEqual(mapped_uri, expected_uri,
                                  "Mapped URI was not expected: %r != %r (mappedPath: %r)" %
                                  (mapped_uri, expected_uri, mappedPath))
             unmapped_path = uriparse.getMappedPath(mapped_uri, prefs)
             self.failUnlessEqual(unmapped_path, path,
                                  "Mapped URI was not unmapped correctly: %r != %r (mappedPath: %r)" %
                                  (unmapped_path, path, mappedPath))