Ticket #68: test_introducers_cfg.py

File test_introducers_cfg.py, 1.1 KB (added by writefaruq, at 2010-07-22T12:12:52Z)

Check if a new "introducers" cfg file can be created and tahoe.cfg's introducer_furl can be written in this file

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