# HG changeset patch # User Ben Croston # Date 1315224487 -3600 # Node ID 45c1d78559e28c7f6af6887883f619bdf21f5b5d # Parent 21eb67081c4331f16ed4cafd037d4ef2c3193251 Added more tests diff -r 21eb67081c43 -r 45c1d78559e2 wibble/tests.py --- a/wibble/tests.py Mon Sep 05 12:42:05 2011 +0100 +++ b/wibble/tests.py Mon Sep 05 13:08:07 2011 +0100 @@ -26,6 +26,13 @@ import time from wsgiref import simple_server import platform +import urllib + +try: + urllib.urlopen('http://www.wyre-it.co.uk/') + NO_INTERNET = False +except IOError: + NO_INTERNET = True ##### server vvv ##### class api(object): @@ -80,6 +87,22 @@ with self.assertRaises(UnauthorisedException): self.assertEqual(self.client.api.mymethod(),self.client.mymethod()) + +@unittest.skipIf(NO_INTERNET,'www.wyre-it.co.uk:80 not contactable') +class NotFoundTest(unittest.TestCase): + def runTest(self): + from client import ServerProxy, NotFoundException + self.client = ServerProxy('http://www.wyre-it.co.uk/notfound.txt') + with self.assertRaises(NotFoundException): + self.assertEqual(self.client.api.mymethod(),self.client.mymethod()) + +class NetworkSocketTest(unittest.TestCase): + def runTest(self): + from client import ServerProxy, NetworkSocketException + self.client = ServerProxy('http://localhost:666/') + with self.assertRaises(NetworkSocketException): + self.assertEqual(self.client.api.mymethod(),self.client.mymethod()) + class WibbleTests(unittest.TestCase): def setUp(self): from client import ServerProxy @@ -132,6 +155,8 @@ # tests are as client suite = unittest.TestSuite() suite.addTest(AuthTest()) + suite.addTest(NotFoundTest()) + suite.addTest(NetworkSocketTest()) suite.addTest(IgnoreClassNameTest()) suite.addTest(ExceptionTest()) suite.addTest(BadRequestTest())