24
24
from fixtures import TestCaseWithFixtures
27
class DashboardTests(TestCaseWithFixtures):
27
class SetupTests(TestCaseWithFixtures):
29
super(DashboardTests, self).setUp()
29
super(SetupTests, self).setUp()
30
30
self.config = self.add_fixture(ConfigImposter())
32
32
def test_dashboard_setup(self):
36
args = ["setup", server, "-u", user, "-p", passwd]
33
host, user, passwd = setup_dashboard()
39
34
conf = DashboardConfig()
40
self.assertEqual(server, conf.host)
35
self.assertEqual(host, conf.host)
41
36
self.assertEqual(user, conf.user)
42
37
self.assertEqual(passwd, conf.password)
44
class DashboardOutputTests(TestCaseWithFixtures):
40
class SetupOutputTests(TestCaseWithFixtures):
46
super(DashboardOutputTests, self).setUp()
42
super(SetupOutputTests, self).setUp()
47
43
self.out = self.add_fixture(OutputImposter())
49
45
def test_dashboard_setup_noserver(self):
52
48
self.assertRaises(SystemExit, cmd.main, argv=[])
53
49
self.assertEqual(errmsg, self.out.getvalue().strip())
52
class BundleOutputTests(TestCaseWithFixtures):
54
super(BundleOutputTests, self).setUp()
55
self.out = self.add_fixture(OutputImposter())
55
57
def test_dashboard_bundle_badresult(self):
56
58
errmsg = "Result directory not found"
57
59
cmd = subcmd_dashboard_bundle()
64
66
self.assertRaises(SystemExit, cmd.main, argv=[])
65
67
self.assertEqual(errmsg, self.out.getvalue().strip())
68
class DashboardConfigOutputTests(TestCaseWithFixtures):
69
class BundleConfigOutputTests(TestCaseWithFixtures):
70
super(DashboardConfigOutputTests, self).setUp()
71
super(BundleConfigOutputTests, self).setUp()
71
72
self.config = self.add_fixture(ConfigImposter())
72
73
self.out = self.add_fixture(OutputImposter())
113
114
self.assertEqual(expected_dict, returned_dict)
117
class PutConfigOutputTests(TestCaseWithFixtures):
119
super(PutConfigOutputTests, self).setUp()
120
self.config = self.add_fixture(ConfigImposter())
121
self.out = self.add_fixture(OutputImposter())
123
def test_put_nosetup(self):
124
testname, testuuid = make_stream_result(self.config)
125
errmsg = "Error connecting to server, please run 'abrek dashboard " \
127
args = ["put", "somestream", testname]
128
cmd = cmd_dashboard()
129
self.assertRaises(SystemExit, cmd.main, argv=args)
130
self.assertEqual(errmsg, self.out.getvalue().strip())
132
def test_put_badhost(self):
133
testname, testuuid = make_stream_result(self.config)
134
host, user, passwd = setup_dashboard(host = "http://badhost.foo")
135
errmsg = "Unable to connect to host: [Errno -2] Name or service " \
137
args = ["put", "somestream", testname]
138
cmd = cmd_dashboard()
139
self.assertRaises(SystemExit, cmd.main, argv=args)
140
self.assertEqual(errmsg, self.out.getvalue().strip())
143
class PutOutputTests(TestCaseWithFixtures):
145
super(PutOutputTests, self).setUp()
146
self.out = self.add_fixture(OutputImposter())
148
def test_put_noargs(self):
149
errmsg = "You must specify a stream and a result"
150
cmd = cmd_dashboard()
151
self.assertRaises(SystemExit, cmd.main, argv=["put"])
152
self.assertEqual(errmsg, self.out.getvalue().strip())
116
155
def make_stream_result(config):
118
157
Make a fake set of test results for the stream test
144
183
with open(os.path.join(result_dir, "testoutput.log"), "w") as fd:
145
184
fd.write(testoutput_data)
146
185
return (testname, testuuid)
187
def setup_dashboard(host="http://localhost:8080", user="foo", passwd="baz"):
188
args = ["setup", host, "-u", user, "-p", passwd]
189
cmd = cmd_dashboard()
191
return host, user, passwd