1 | #!/usr/bin/python |
---|
2 | import os, sys |
---|
3 | import unittest |
---|
4 | from mock import Mock, patch, sentinel |
---|
5 | |
---|
6 | from allmydata.introducer.client import IntroducerClient |
---|
7 | from allmydata.client import Client, MULTI_INTRODUCERS_CFG |
---|
8 | from allmydata.scripts.create_node import write_node_config |
---|
9 | |
---|
10 | class 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 | |
---|
32 | if __name__ == "__main__": |
---|
33 | unittest.main() |
---|