1from PyObjCTools.TestSupport import *
2
3from Foundation import *
4
5try:
6    unicode
7except NameError:
8    unicode = str
9
10class TestNSConnectionHelper (NSObject):
11    def makeNewConnection_sender_(self, a, b): return 1
12    def connection_shouldMakeNewConnection_(self, a, b): return 1
13    def authenticateComponents_withData_(self, a, b): return 1
14    def connection_handleRequest_(self, a, b): return 1
15
16class TestNSConnection (TestCase):
17    def testConstants(self):
18        self.assertIsInstance(NSConnectionReplyMode, unicode)
19        self.assertIsInstance(NSConnectionDidDieNotification, unicode)
20        self.assertIsInstance(NSFailedAuthenticationException, unicode)
21        self.assertIsInstance(NSConnectionDidInitializeNotification, unicode)
22
23    def testMethods(self):
24        self.assertArgIsBOOL(NSConnection.setIndependentConversationQueueing_, 0)
25        self.assertResultIsBOOL(NSConnection.independentConversationQueueing)
26        self.assertResultIsBOOL(NSConnection.isValid)
27        self.assertResultIsBOOL(NSConnection.registerName_)
28        self.assertResultIsBOOL(NSConnection.registerName_withNameServer_)
29        self.assertResultIsBOOL(NSConnection.multipleThreadsEnabled)
30
31    def testProtocols(self):
32        self.assertResultIsBOOL(TestNSConnectionHelper.makeNewConnection_sender_)
33        self.assertResultIsBOOL(TestNSConnectionHelper.connection_shouldMakeNewConnection_)
34        self.assertResultIsBOOL(TestNSConnectionHelper.authenticateComponents_withData_)
35        self.assertResultIsBOOL(TestNSConnectionHelper.connection_handleRequest_)
36
37if __name__ == "__main__":
38    main()
39