Example #1
0
 def test_multiSeparatorSplit_predefined(self):
     """ Separates input string by multiple separators. Input is string, result is list."""
     url=SmartURL("http://foo.com/blah_blah_(wikipedia)")
     idx=0
     for urlString in self.testURLs:
         url=SmartURL(urlString)
         self.assertEqual(url.multiSeparatorSplit(url.Composed,self.settings.urlWordsSeparators),self.manuallyWordedURLs[idx])
         idx+=1
Example #2
0
 def test_SmartURL_seed(self):
     """ SmartURL has a seed. The seed doesn't change when splitted or composed change."""
     url=SmartURL("http://foo.com/blah_blah_(wikipedia)")
     seed=copy.copy(url.Seed)
     url.Composed="http://foo.com/blah_blah"
     self.assertEqual(seed,url.Seed)
     url=SmartURL("http://foo.com/blah_blah_(wikipedia)")
     url.Splitted=["http:","","foo.com","blah_blah","(nonsense)"]
     self.assertEqual(seed,url.Seed)
Example #3
0
 def test_SmartURL_changes(self):
     """SmartURL: If either splitted or composed changes, the other changes accordingly."""
     url=SmartURL("http://foo.com/blah_blah_(wikipedia)")
     url.Composed="http://bar.com/blah_blah_(wikipedia)"
     self.assertEqual(url.Composed,"http://bar.com/blah_blah_(wikipedia)") # 026 First check if Composed was really changed.
     self.assertEqual(["http:","","bar.com","blah_blah_(wikipedia)"],url.Splitted) # 026 Then check if the change was reflected by Splitted.
     url=SmartURL("http://www.kosek.cz/clanky/swn-xml/ar02s17.html")
     url.Splitted=["http:","","www.vrabec.cz","clanky","swn-xml","ar03s18.html"]
     self.assertEqual(url.Splitted,["http:","","www.vrabec.cz","clanky","swn-xml","ar03s18.html"]) # 026 First check if Splitted was really changed.
     self.assertEqual(url.Composed,"http://www.vrabec.cz/clanky/swn-xml/ar03s18.html") # 026 Then check if the change was reflected by Composed.
Example #4
0
    def test_SmartURL_relative(self):
        """ SmartURL has methods isAbsolute, isRelative. """
        url=SmartURL("http://argouml-stats.tigris.org/documentation/manual-0.26/ch02.html")
        self.assertFalse(url.isRelative())
        self.assertTrue(url.isAbsolute())
        url=SmartURL("documentation/manual-0.26/ch02.html")
        self.assertFalse(url.isAbsolute())
        self.assertTrue(url.isRelative())

        """
Example #5
0
 def test_multiSeparatorSplit_custom(self):
     """ Separates input string by multiple separators. Input is string, result is list."""
     
     input="x-yojimbo-item://6303E4C1-6A6E-45A6-AB9D-3A908F59AE0E"
     output=["x","yojimbo","item://6303E4C1","6A6E","45A6","AB9D","3A908F59AE0E"]
     splitters=['-']
     url=SmartURL(input)
     self.assertEqual(url.multiSeparatorSplit(input,splitters),output)
     
     input="x-yojimbo-item://6303E4C1-6A6E-45A6-AB9D-3A908F59AE0E"
     output=["x-yojimbo-item://6303E4C1-6A6E-45A6-AB9D-3A908F59AE0E"]
     splitters=[' ']
     url=SmartURL(input)
     self.assertEqual(url.multiSeparatorSplit(input,splitters),output)
     
     input="Skakal pes pres oves, pres zelenou louku."
     output=["Skakal","pes","pres","oves,","pres","zelenou","louku."]
     splitters=[' ']
     url=SmartURL(input)
     self.assertEqual(url.multiSeparatorSplit(input,splitters),output)