Changeset 57868 in webkit
- Timestamp:
- Apr 19, 2010 9:34:10 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r57863 r57868 1 2010-04-19 Daniel Bates <dbates@rim.com> 2 3 Reviewed by Adam Barth. 4 5 https://bugs.webkit.org/show_bug.cgi?id=37748 6 7 Make Sheriffbot more inspirational. 8 9 * Scripts/webkitpy/common/net/bugzilla.py: 10 * Scripts/webkitpy/common/net/bugzilla_unittest.py: 11 * Scripts/webkitpy/tool/bot/irc_command.py: 12 * Scripts/webkitpy/tool/bot/sheriffircbot_unittest.py: 13 * Scripts/webkitpy/tool/mocktool.py: 14 1 15 2010-04-19 Kevin Ollivier <kevino@theolliviers.com> 2 16 -
trunk/WebKitTools/Scripts/webkitpy/common/net/bugzilla.py
r57195 r57868 43 43 from webkitpy.common.system.user import User 44 44 from webkitpy.thirdparty.autoinstalled.mechanize import Browser 45 from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup, SoupStrainer45 from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, SoupStrainer 46 46 47 47 … … 266 266 review_queue_url = "request.cgi?action=queue&type=review&group=type" 267 267 return self._fetch_attachment_ids_request_query(review_queue_url) 268 269 def fetch_quips(self): 270 return self._load_query("/quips.cgi?action=show") 271 272 def parse_quips(self, page, limit=None): 273 soup = BeautifulSoup(page, convertEntities=BeautifulStoneSoup.HTML_ENTITIES) 274 quips = soup.find(text=re.compile("Existing quips:")).findNext("ul").findAll("li")[:limit] 275 return [str(quip_entry.string) for quip_entry in quips] 268 276 269 277 … … 365 373 self.queries = BugzillaQueries(self) 366 374 self.committers = committers 375 self.cached_quips = [] 367 376 368 377 # FIXME: We should use some sort of Browser mock object when in dryrun … … 377 386 bug_server_regex = "https?://%s/" % re.sub('\.', '\\.', bug_server_host) 378 387 bug_server_url = "https://%s/" % bug_server_host 388 389 def quips(self): 390 # We only fetch and parse the list of quips once per instantiation 391 # so that we do not burden bugs.webkit.org. 392 if not self.cached_quips: 393 self.cached_quips = self.queries.parse_quips(self.queries.fetch_quips()) 394 return self.cached_quips 379 395 380 396 def bug_url_for_bug_id(self, bug_id, xml=False): -
trunk/WebKitTools/Scripts/webkitpy/common/net/bugzilla_unittest.py
r56835 r57868 308 308 </html> 309 309 """ 310 _sample_quip_page = """ 311 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 312 "http://www.w3.org/TR/html4/loose.dtd"> 313 <html> 314 <head> 315 <title>Bugzilla Quip System</title> 316 </head> 317 <body> 318 <h2> 319 320 Existing quips: 321 </h2> 322 <ul> 323 <li>Everything should be made as simple as possible, but not simpler. - Albert Einstein</li> 324 <li>Good artists copy. Great artists steal. - Pablo Picasso</li> 325 326 </ul> 327 </body> 328 </html> 329 """ 310 330 311 331 def test_request_page_parsing(self): … … 313 333 self.assertEquals([40511, 40722, 40723], queries._parse_attachment_ids_request_query(self._sample_request_page)) 314 334 335 def test_quip_page_parsing(self): 336 queries = BugzillaQueries(None) 337 expected_quips = ["Everything should be made as simple as possible, but not simpler. - Albert Einstein", "Good artists copy. Great artists steal. - Pablo Picasso"] 338 self.assertEquals(expected_quips, queries.parse_quips(self._sample_quip_page)) 339 315 340 def test_load_query(self): 316 341 queries = BugzillaQueries(Mock()) -
trunk/WebKitTools/Scripts/webkitpy/tool/bot/irc_command.py
r56977 r57868 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 import random 29 30 import webkitpy.common.config.irc as config_irc 30 31 … … 77 78 class Hi(IRCCommand): 78 79 def execute(self, nick, args, tool, sheriff): 79 return '"Only you can prevent forest fires." -- Smokey the Bear' 80 quips = tool.bugs.quips() 81 quips.append('"Only you can prevent forest fires." -- Smokey the Bear') 82 return random.choice(quips) -
trunk/WebKitTools/Scripts/webkitpy/tool/bot/sheriffircbot_unittest.py
r57011 r57868 28 28 29 29 import unittest 30 import random 30 31 31 32 from webkitpy.common.system.outputcapture import OutputCapture … … 46 47 class SheriffIRCBotTest(unittest.TestCase): 47 48 def test_hi(self): 49 random.seed(23324) 48 50 expected_stderr = 'MOCK: irc.post: "Only you can prevent forest fires." -- Smokey the Bear\n' 49 51 OutputCapture().assert_outputs(self, run, args=["hi"], expected_stderr=expected_stderr) -
trunk/WebKitTools/Scripts/webkitpy/tool/mocktool.py
r57587 r57868 271 271 log("bug_description: %s" % bug_description) 272 272 273 def quips(self): 274 return ["Good artists copy. Great artists steal. - Pablo Picasso"] 275 273 276 def fetch_bug(self, bug_id): 274 277 return Bug(self.bug_cache.get(bug_id), self)
Note: See TracChangeset
for help on using the changeset viewer.