• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 23. Availability of Content via ... > Step 2: Testing the XML-RPC Views

Step 2: Testing the XML-RPC Views

Of course, the testing code is many times more complex than the implementation of the feature because you have to bring up the component architecture and the event service manually. As in the implementation, you can place the container-related tests in a base class (the code should be located in tests/test_xmlrpc.py):

01 from zope.app.tests.placelesssetup import PlacelessSetup
02
03 class MessageContainerTest(PlacelessSetup):
04
05     def _makeMethodObject(self):
06         return NotImplemented
07
08     def _makeTree(self):
09         methods = self._makeMethodObject()
10         msg1 = Message()
11         msg1.title = 'Message 1'
12         msg1.description = 'This is Message 1.'
13         msg2 = Message()
14         msg2.title = 'Message 1'
15         msg2.description = 'This is Message 1.'
16         methods.context['msg1'] = msg1
17         methods.context['msg2'] = msg2
18         return methods
19
20     def test_getMessageNames(self):
21         methods = self._makeTree()
22         self.assert_(isinstance(methods.getMessageNames(), list))
23         self.assertEqual(list(methods.context.keys()),
24                          methods.getMessageNames())
25
26     def test_addMessage(self):
27         methods = self._makeTree()
28         self.assertEqual(methods.addMessage('msg3', 'M3', 'MB3'), 
29                          'msg3')
30         self.assertEqual(methods.context['msg3'].title, 'M3')
31         self.assertEqual(methods.context['msg3'].body, 'MB3')
32
33     def test_deleteMessage(self):
34         methods = self._makeTree()
35         self.assertEqual(methods.deleteMessage('msg2'), True)
36         self.assertEqual(list(methods.context.keys()), ['msg1'])


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint