# HG changeset patch # User Ben Croston # Date 1315222148 -3600 # Node ID 4ac14cfadc15aa8de94dff40ef3bce218bf0dbe9 # Parent dbd55e6af4f6fe7cca2282541b970ba69478bb4e Improved AuthTest diff -r dbd55e6af4f6 -r 4ac14cfadc15 wibble/tests.py --- a/wibble/tests.py Mon Sep 05 12:13:45 2011 +0100 +++ b/wibble/tests.py Mon Sep 05 12:29:08 2011 +0100 @@ -56,7 +56,7 @@ ##### server ^^^ ##### ##### client vvv ##### -class NotAuthTest(unittest.TestCase): +class AuthTest(unittest.TestCase): def runTest(self): from client import ServerProxy, UnauthorisedException self.client = ServerProxy('http://localhost:1337/', @@ -66,6 +66,20 @@ with self.assertRaises(UnauthorisedException): self.assertEqual(self.client.api.mymethod(),self.client.mymethod()) + self.client = ServerProxy('http://localhost:1337/', + username='testuser', + password='wrongpassword', + user_agent='wibble_unittest') + with self.assertRaises(UnauthorisedException): + self.assertEqual(self.client.api.mymethod(),self.client.mymethod()) + + self.client = ServerProxy('http://localhost:1337/', + username='wronguser', + password='s3cr3t', + user_agent='wibble_unittest') + with self.assertRaises(UnauthorisedException): + self.assertEqual(self.client.api.mymethod(),self.client.mymethod()) + class WibbleTests(unittest.TestCase): def setUp(self): from client import ServerProxy @@ -117,7 +131,7 @@ # tests are as client suite = unittest.TestSuite() - suite.addTest(NotAuthTest()) + suite.addTest(AuthTest()) suite.addTest(IgnoreClassNameTest()) suite.addTest(ExceptionTest()) suite.addTest(BadRequestTest())