source: uri/tests/UriTest.py@ 264

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

#94 fix URI test code

File size: 1.0 KB
RevLine 
[231]1import unittest
[233]2from 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")
8
9 def testGetUri(self):
10 self.assertEqual("ws://localhost:8080/bla/2/3?q=hello#zozo", self.u2.getUri())
[231]11
[264]12 def testRepr(self):
13 self.assertEqual("ws://localhost:8080/bla/2/3?q=hello#zozo", repr(self.u2))
14
15 def testGetHost(self):
16 self.assertEqual("localhost", self.u2.getHost())
[231]17
[264]18 def testGetScheme(self):
19 self.assertEqual("ws", self.u2.getScheme())
[231]20
[264]21 def testGetFragment(self):
22 self.assertEqual("zozo", self.u2.getFragment())
[231]23
[264]24 def testGetQuery(self):
25 self.assertEqual("q=hello", self.u2.getQuery())
[232]26
[264]27 def testHashEq(self):
28 self.assertEqual(self.u1, self.u1a)
29 self.assertEqual(hash(self.u1), hash(self.u1a))
30
31 def testRaisesError(self):
32 self.assertRaises(AssertionError, lambda:URI("!"))
33 self.assertRaises(AssertionError, lambda:URI("path"))
34
Note: See TracBrowser for help on using the repository browser.