Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: pylibs/buildbot/test/test_web_status_json.py

Issue 809001: Rename a few variables and greatly reduce the amount of data sent for steps* events (Closed)
Patch Set: Rebase against trunk and fix the unit test again Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pylibs/buildbot/test/test_status_push.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # -*- test-case-name: buildbot.test.test_web_status_json -*- 1 # -*- test-case-name: buildbot.test.test_web_status_json -*-
2 # -*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3 3
4 import os, shutil 4 import os, shutil
5 5
6 from twisted.python import components 6 from twisted.python import components
7 from twisted.trial import unittest 7 from twisted.trial import unittest
8 from twisted.web import client, error 8 from twisted.web import client, error
9 9
10 from buildbot import master, interfaces 10 from buildbot import master, interfaces
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 BuildmasterConfig = c = { 44 BuildmasterConfig = c = {
45 'change_source': PBChangeSource(), 45 'change_source': PBChangeSource(),
46 'slaves': [BuildSlave('bot1name', 'bot1passwd')], 46 'slaves': [BuildSlave('bot1name', 'bot1passwd')],
47 'schedulers': [Scheduler('name', None, 60, ['builder1'])], 47 'schedulers': [Scheduler('name', None, 60, ['builder1'])],
48 'slavePortnum': 0, 48 'slavePortnum': 0,
49 } 49 }
50 c['builders'] = [ 50 c['builders'] = [
51 BuilderConfig(name='builder1', slavename='bot1name', factory=BuildFactory()) , 51 BuilderConfig(name='builder1', slavename='bot1name', factory=BuildFactory()) ,
52 ] 52 ]
53 c['slavePortnum'] = 0
54 c['projectUrl'] = 'example.com/yay'
55 c['projectName'] = 'Pouet'
56 c['buildbotURL'] = 'build.example.com/yo'
53 """ 57 """
54 58
55 59
56 class TestStatusJson(unittest.TestCase): 60 class TestStatusJson(unittest.TestCase):
57 def setUp(self): 61 def setUp(self):
58 config = base_config + "c['status'] = [html.WebStatus(http_port=0)]\n" 62 config = base_config + "c['status'] = [html.WebStatus(http_port=0)]\n"
59 if os.path.isdir('test_web1'): 63 if os.path.isdir('test_web1'):
60 shutil.rmtree('test_web1') 64 shutil.rmtree('test_web1')
61 os.mkdir('test_web1') 65 os.mkdir('test_web1')
62 self.master = ConfiguredMaster('test_web1', config) 66 self.master = ConfiguredMaster('test_web1', config)
(...skipping 20 matching lines...) Expand all
83 d = client.getPage('http://localhost:%d%s' % (self.port, url)) 87 d = client.getPage('http://localhost:%d%s' % (self.port, url))
84 if cb: 88 if cb:
85 d.addCallback(cb) 89 d.addCallback(cb)
86 if err: 90 if err:
87 d.addErrback(err) 91 d.addErrback(err)
88 return d 92 return d
89 93
90 def testPresence(self): 94 def testPresence(self):
91 def _check(page): 95 def _check(page):
92 data = json.loads(page) 96 data = json.loads(page)
93 self.assertEqual(len(data), 4) 97 EXPECTED = {
94 self.assertEqual(len(data['builders']), 1) 98 'builders': {
95 self.assertEqual(len(data['change_sources']), 1) 99 'builder1': {
96 self.assertEqual(len(data['project']), 2) 100 'basedir': 'builder1',
97 self.assertEqual(len(data['slaves']), 1) 101 'cachedBuilds': [],
102 'category': None,
103 'currentBuilds': [],
104 'pendingBuilds': [],
105 'slaves': ['bot1name'],
106 'state': 'offline'
107 }
108 },
109 'change_sources': {
110 '0': {
111 'description': 'PBChangeSource listener on all-purpose s laveport'
112 }
113 },
114 'project': {
115 'buildbotURL': 'build.example.com/yo',
116 'projectName': 'Pouet',
117 'projectURL': None
118 },
119 'slaves': {
120 'bot1name': {
121 'access_uri': None,
122 'admin': None,
123 'builders': {u'builder1': []},
124 'connected': False,
125 'host': None,
126 'name': u'bot1name',
127 'runningBuilds': [],
128 'version': None
129 }
130 }
131 }
132 self.assertEqual(EXPECTED, data)
98 return self.getPage('/json', _check) 133 return self.getPage('/json', _check)
99 134
100 def testHelp(self): 135 def testHelp(self):
101 def _check(page): 136 def _check(page):
102 self.failUnless(page) 137 self.failUnless(page)
103 return self.getPage('/json/help', _check) 138 return self.getPage('/json/help', _check)
104 139
105 def testNonPresence(self): 140 def testNonPresence(self):
106 def _checkOk(page): 141 def _checkOk(page):
107 self.assertFalse(page) 142 self.assertFalse(page)
108 def _checkFail(result): 143 def _checkFail(result):
109 self.assertEqual(result.type, error.Error) 144 self.assertEqual(result.type, error.Error)
110 return self.getPage('/json2', _checkOk, _checkFail) 145 return self.getPage('/json2', _checkOk, _checkFail)
111 146
112 # vim: set ts=4 sts=4 sw=4 et: 147 # vim: set ts=4 sts=4 sw=4 et:
OLDNEW
« no previous file with comments | « pylibs/buildbot/test/test_status_push.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698