~pwlars/lava-test/gtkperf-fixes

« back to all changes in this revision

Viewing changes to tests/test_dashboard.py

  • Committer: Paul Larson
  • Date: 2010-10-08 21:37:41 UTC
  • mfrom: (40.3.8 dashboard-put)
  • Revision ID: paul.larson@canonical.com-20101008213741-526oo42sdvzpgtph
Add a put command to dashboard

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from fixtures import TestCaseWithFixtures
25
25
 
26
26
 
27
 
class DashboardTests(TestCaseWithFixtures):
 
27
class SetupTests(TestCaseWithFixtures):
28
28
    def setUp(self):
29
 
        super(DashboardTests, self).setUp()
 
29
        super(SetupTests, self).setUp()
30
30
        self.config = self.add_fixture(ConfigImposter())
31
31
 
32
32
    def test_dashboard_setup(self):
33
 
        server = "foo"
34
 
        user = "bar"
35
 
        passwd = "baz"
36
 
        args = ["setup", server, "-u", user, "-p", passwd]
37
 
        cmd = cmd_dashboard()
38
 
        cmd.main(argv=args)
 
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)
43
38
 
44
 
class DashboardOutputTests(TestCaseWithFixtures):
 
39
 
 
40
class SetupOutputTests(TestCaseWithFixtures):
45
41
    def setUp(self):
46
 
        super(DashboardOutputTests, self).setUp()
 
42
        super(SetupOutputTests, self).setUp()
47
43
        self.out = self.add_fixture(OutputImposter())
48
44
 
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())
54
50
 
 
51
 
 
52
class BundleOutputTests(TestCaseWithFixtures):
 
53
    def setUp(self):
 
54
        super(BundleOutputTests, self).setUp()
 
55
        self.out = self.add_fixture(OutputImposter())
 
56
 
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())
66
68
 
67
 
 
68
 
class DashboardConfigOutputTests(TestCaseWithFixtures):
 
69
class BundleConfigOutputTests(TestCaseWithFixtures):
69
70
    def setUp(self):
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())
73
74
 
113
114
        self.assertEqual(expected_dict, returned_dict)
114
115
 
115
116
 
 
117
class PutConfigOutputTests(TestCaseWithFixtures):
 
118
    def setUp(self):
 
119
        super(PutConfigOutputTests, self).setUp()
 
120
        self.config = self.add_fixture(ConfigImposter())
 
121
        self.out = self.add_fixture(OutputImposter())
 
122
 
 
123
    def test_put_nosetup(self):
 
124
        testname, testuuid = make_stream_result(self.config)
 
125
        errmsg = "Error connecting to server, please run 'abrek dashboard " \
 
126
                "setup [host]'"
 
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())
 
131
 
 
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 " \
 
136
                "not known"
 
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())
 
141
 
 
142
 
 
143
class PutOutputTests(TestCaseWithFixtures):
 
144
    def setUp(self):
 
145
        super(PutOutputTests, self).setUp()
 
146
        self.out = self.add_fixture(OutputImposter())
 
147
 
 
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())
 
153
 
 
154
 
116
155
def make_stream_result(config):
117
156
    """
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)
 
186
 
 
187
def setup_dashboard(host="http://localhost:8080", user="foo", passwd="baz"):
 
188
    args = ["setup", host, "-u", user, "-p", passwd]
 
189
    cmd = cmd_dashboard()
 
190
    cmd.main(argv=args)
 
191
    return host, user, passwd