Ticket #68: test_introducers_cfg.2.py

File test_introducers_cfg.2.py, 1.0 KB (added by writefaruq, at 2010-07-31T17:09:38Z)

code refined by pyflakes

Line 
1#!/usr/bin/python
2import os
3import unittest
4
5from allmydata.client import Client, MULTI_INTRODUCERS_CFG
6from allmydata.scripts.create_node import write_node_config
7
8class TestClient(unittest.TestCase):
9   
10    def test_read_introducer_furl_from_tahoecfg(self):
11        """ Ensure that the Client reads the introducer.furl config item from
12        the tahoe.cfg file. """
13        c = open(os.path.join("tahoe.cfg"), "w")
14        config = {}
15        write_node_config(c, config)
16        fake_furl = "furl1"
17        c.write("[client]\n")
18        c.write("introducer.furl = %s\n" % fake_furl)       
19        c.close()
20
21        # get a client and first introducer_furl
22        myclient = Client()       
23        tahoe_cfg_furl = myclient.introducer_furls[0]
24        # "introducers" file contains introducer_furl from tahoe.cfg               
25        furl = open(MULTI_INTRODUCERS_CFG).readline().rstrip()
26        #print "got furl: %s" %furl
27
28        self.failUnlessEqual(fake_furl, tahoe_cfg_furl)
29
30if __name__ == "__main__":
31    unittest.main()