source: uri/tests/UriTest.py@ 1358

Last change on this file since 1358 was 305, checked in by wouter, 3 years ago

added few more tests.

File size: 1.4 KB
RevLine 
[231]1import unittest
[297]2from uri.uri import URI
[231]3
4class OfferTest (unittest.TestCase) :
[264]5 u1=URI("http://blabla")
6 u1a=URI("hTTP://blaBla")
7 u2=URI("ws://localhost:8080/bla/2/3?q=hello#zozo")
[305]8 u3=URI("classpath:geniusweb.exampleparties.randomparty.RandomParty")
[264]9
10 def testGetUri(self):
11 self.assertEqual("ws://localhost:8080/bla/2/3?q=hello#zozo", self.u2.getUri())
[231]12
[264]13 def testRepr(self):
14 self.assertEqual("ws://localhost:8080/bla/2/3?q=hello#zozo", repr(self.u2))
15
16 def testGetHost(self):
17 self.assertEqual("localhost", self.u2.getHost())
[231]18
[264]19 def testGetScheme(self):
20 self.assertEqual("ws", self.u2.getScheme())
[305]21 self.assertEqual("classpath", self.u3.getScheme())
[231]22
[264]23 def testGetFragment(self):
24 self.assertEqual("zozo", self.u2.getFragment())
[231]25
[264]26 def testGetQuery(self):
27 self.assertEqual("q=hello", self.u2.getQuery())
[232]28
[264]29 def testHashEq(self):
30 self.assertEqual(self.u1, self.u1a)
31 self.assertEqual(hash(self.u1), hash(self.u1a))
[305]32
33 def testGetPath(self):
34 self.assertEqual("/bla/2/3", self.u2.getPath())
35 self.assertEqual("geniusweb.exampleparties.randomparty.RandomParty",
36 self.u3.getPath())
[266]37
38# def testRaisesError(self):
39# self.assertRaises(AssertionError, lambda:URI("!"))
40# self.assertRaises(AssertionError, lambda:URI("path"))
41#
Note: See TracBrowser for help on using the repository browser.