Example #1
0
    def test_find_destination_with_infix(self):
        desmap = DestinationMap()

        desmap.__set_destination__("http://a.name.com/path/ignored", "local/folder/a")
        uri = "http://a.name.com/path/ignored/but/this/path/remains/file.txt"
        base_uri, destination = desmap.find_destination(uri, infix="resources")
        self.assertEqual("http://a.name.com/path/ignored", base_uri)
        self.assertEqual("./local/folder/a/resources", destination)

        base_uri, destination = desmap.find_destination(uri, infix="sitemaps")
        self.assertEqual("http://a.name.com/path/ignored", base_uri)
        self.assertEqual("./local/folder/a/sitemaps", destination)
Example #2
0
    def test_find_destination_with_infix(self):
        desmap = DestinationMap()

        desmap.__set_destination__("http://a.name.com/path/ignored",
                                   "local/folder/a")
        uri = "http://a.name.com/path/ignored/but/this/path/remains/file.txt"
        base_uri, destination = desmap.find_destination(uri, infix="resources")
        self.assertEqual("http://a.name.com/path/ignored", base_uri)
        self.assertEqual("./local/folder/a/resources", destination)

        base_uri, destination = desmap.find_destination(uri, infix="sitemaps")
        self.assertEqual("http://a.name.com/path/ignored", base_uri)
        self.assertEqual("./local/folder/a/sitemaps", destination)
Example #3
0
    def test_find_local_path(self):
        desmap = DestinationMap()

        desmap.__set_destination__("http://a.name.com/path/ignored",
                                   "local/folder/a")
        uri = "http://a.name.com/path/ignored/but/this/path/remains/file.txt"
        base_uri, local_path = desmap.find_local_path(uri)
        self.assertEqual("http://a.name.com/path/ignored", base_uri)
        self.assertEqual("./local/folder/a/but/this/path/remains/file.txt",
                         local_path)

        desmap.__set_destination__("http://b.name.com/path/ignored/",
                                   "local/folder/b")
        uri = "http://b.name.com/path/ignored/but/this/path/remains/file.txt"
        base_uri, local_path = desmap.find_local_path(uri)
        self.assertEqual("http://b.name.com/path/ignored", base_uri)
        self.assertEqual("./local/folder/b/but/this/path/remains/file.txt",
                         local_path)

        desmap.__set_destination__("http://c.name.com/path/ignored",
                                   "local/folder/c")
        uri = "http://c.name.com/path/ignored/but/this/path/remains/file.txt"
        base_uri, local_path = desmap.find_local_path(uri, infix="infix")
        self.assertEqual("http://c.name.com/path/ignored", base_uri)
        self.assertEqual(
            "./local/folder/c/infix/but/this/path/remains/file.txt",
            local_path)
Example #4
0
    def test_find_local_path(self):
        desmap = DestinationMap()

        desmap.__set_destination__("http://a.name.com/path/ignored", "local/folder/a")
        uri = "http://a.name.com/path/ignored/but/this/path/remains/file.txt"
        base_uri, local_path = desmap.find_local_path(uri)
        self.assertEqual("http://a.name.com/path/ignored", base_uri)
        self.assertEqual("./local/folder/a/but/this/path/remains/file.txt", local_path)

        desmap.__set_destination__("http://b.name.com/path/ignored/", "local/folder/b")
        uri = "http://b.name.com/path/ignored/but/this/path/remains/file.txt"
        base_uri, local_path = desmap.find_local_path(uri)
        self.assertEqual("http://b.name.com/path/ignored", base_uri)
        self.assertEqual("./local/folder/b/but/this/path/remains/file.txt", local_path)

        desmap.__set_destination__("http://c.name.com/path/ignored", "local/folder/c")
        uri = "http://c.name.com/path/ignored/but/this/path/remains/file.txt"
        base_uri, local_path = desmap.find_local_path(uri, infix="infix")
        self.assertEqual("http://c.name.com/path/ignored", base_uri)
        self.assertEqual("./local/folder/c/infix/but/this/path/remains/file.txt", local_path)