Mercurial > hg > AuthRPC
changeset 14:45c1d78559e2
Added more tests
author | Ben Croston <ben@croston.org> |
---|---|
date | Mon, 05 Sep 2011 13:08:07 +0100 |
parents | 21eb67081c43 |
children | 3c19ae16fc7a |
files | wibble/tests.py |
diffstat | 1 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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())