Package openid :: Package test :: Module test_extension
[frames] | no frames]

Source Code for Module openid.test.test_extension

 1  from openid import extension 
 2  from openid import message 
 3   
 4  import unittest 
 5   
6 -class DummyExtension(extension.Extension):
7 ns_uri = 'http://an.extension/' 8 ns_alias = 'dummy' 9
10 - def getExtensionArgs(self):
11 return {}
12
13 -class ToMessageTest(unittest.TestCase):
14 - def test_OpenID1(self):
15 oid1_msg = message.Message(message.OPENID1_NS) 16 ext = DummyExtension() 17 ext.toMessage(oid1_msg) 18 namespaces = oid1_msg.namespaces 19 self.failUnless(namespaces.isImplicit(DummyExtension.ns_uri)) 20 self.failUnlessEqual( 21 DummyExtension.ns_uri, 22 namespaces.getNamespaceURI(DummyExtension.ns_alias)) 23 self.failUnlessEqual(DummyExtension.ns_alias, 24 namespaces.getAlias(DummyExtension.ns_uri))
25
26 - def test_OpenID2(self):
27 oid2_msg = message.Message(message.OPENID2_NS) 28 ext = DummyExtension() 29 ext.toMessage(oid2_msg) 30 namespaces = oid2_msg.namespaces 31 self.failIf(namespaces.isImplicit(DummyExtension.ns_uri)) 32 self.failUnlessEqual( 33 DummyExtension.ns_uri, 34 namespaces.getNamespaceURI(DummyExtension.ns_alias)) 35 self.failUnlessEqual(DummyExtension.ns_alias, 36 namespaces.getAlias(DummyExtension.ns_uri))
37