source: uri/tests/UriTest.py@ 1099

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

added few more tests.

File size: 1.4 KB
Line 
1import unittest
2from uri.uri import URI
3
4class OfferTest (unittest.TestCase) :
5 u1=URI("http://blabla")
6 u1a=URI("hTTP://blaBla")
7 u2=URI("ws://localhost:8080/bla/2/3?q=hello#zozo")
8 u3=URI("classpath:geniusweb.exampleparties.randomparty.RandomParty")
9
10 def testGetUri(self):
11 self.assertEqual("ws://localhost:8080/bla/2/3?q=hello#zozo", self.u2.getUri())
12
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())
18
19 def testGetScheme(self):
20 self.assertEqual("ws", self.u2.getScheme())
21 self.assertEqual("classpath", self.u3.getScheme())
22
23 def testGetFragment(self):
24 self.assertEqual("zozo", self.u2.getFragment())
25
26 def testGetQuery(self):
27 self.assertEqual("q=hello", self.u2.getQuery())
28
29 def testHashEq(self):
30 self.assertEqual(self.u1, self.u1a)
31 self.assertEqual(hash(self.u1), hash(self.u1a))
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())
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.