Ticket #68: test_root.py

File test_root.py, 1009 bytes (added by writefaruq, at 2010-07-07T22:54:30Z)

corrected test for checking the use of introducer_furl by root.py

Line 
1#!/usr/bin/python
2
3import unittest
4from mock import Mock, patch, sentinel
5
6from allmydata.web.root import Root
7from allmydata.client import Client
8
9class TestRoot(unittest.TestCase):
10   
11    @patch('allmydata.web.root.Root')
12    def test_introducer_furls(self, MockRoot):       
13        # items needed to call data_introducer_furl()
14        mockctx = Mock()
15        mockdata = Mock() 
16        myclient = Client() # Mock() can be set
17        # prepare expected return value:
18        # sentinel.introducer_furl can be set as value
19        ifurl = "pb://7qohn4uiyfpw3xlwg5xavo5mmxfz6eap@192.168.1.3:40338,127.0.0.1:40338/introducer"
20        myclient.introducer_furl = ifurl
21           
22        # Pass mock value to Root
23        myroot = Root(myclient)
24       
25        # make the call
26        furl = myroot.data_introducer_furl(mockctx, mockdata)
27
28       
29        #assertions: compare return value with preset value
30        self.assertEquals(furl, ifurl ) 
31
32if __name__ == "__main__":
33    unittest.main()