Skip to content

Commit

Permalink
Merge branch 'master' into nine
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Apr 29, 2014
2 parents d75d891 + 67e6e05 commit ee6e8bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions master/buildbot/steps/http.py
Expand Up @@ -131,6 +131,7 @@ def doRequest(self):

log.finish()

self.descriptionDone = "Status code: %d" % r.status_code
self.step_status.setText(self.describe(done=True))
if (r.status_code < 400):
self.finished(SUCCESS)
Expand All @@ -156,6 +157,7 @@ def log_response(self, response):
log.addHeader('\t%s: %s\n' % (k, v))

log.addStdout(' ------ Content ------\n%s' % response.text)
self.addLog('content').addStdout(response.text)

def describe(self, done=False):
if done:
Expand Down
22 changes: 13 additions & 9 deletions master/buildbot/test/unit/test_steps_http.py
Expand Up @@ -75,30 +75,34 @@ def test_basic(self):
url = self.getURL()
self.setupStep(http.GET(url))
self.expectLogfile('log', "URL: %s\nStatus: 200\n ------ Content ------\nOK" % (url, ))
self.expectOutcome(result=SUCCESS, status_text=["Requested"])
self.expectLogfile('content', "OK")
self.expectOutcome(result=SUCCESS, status_text=["Status", "code:", '200'])
return self.runStep()

def test_404(self):
url = self.getURL("404")
self.setupStep(http.GET(url))
self.expectLogfile('log', "URL: %s\n ------ Content ------\n404" % (url, ))
self.expectOutcome(result=FAILURE, status_text=["Requested"])
self.expectLogfile('content', "404")
self.expectOutcome(result=FAILURE, status_text=["Status", "code:", '404'])
return self.runStep()

def test_POST(self):
url = self.getURL("POST")
content = "\n<html>\n" \
" <head><title>405 - Method Not Allowed</title></head>\n" \
" <body>\n <h1>Method Not Allowed</h1>\n <p>Your browser " \
"approached me (at /POST) with the method \"POST\". I only allow the " \
"methods HEAD, GET here.</p>\n </body>\n</html>\n"
self.setupStep(http.POST(url))
self.expectLogfile('log', "URL: %s\n ------ Content ------\n\n<html>\n"
" <head><title>405 - Method Not Allowed</title></head>\n"
" <body>\n <h1>Method Not Allowed</h1>\n <p>Your browser "
"approached me (at /POST) with the method \"POST\". I only allow the "
"methods HEAD, GET here.</p>\n </body>\n</html>\n" % (url, ))
self.expectOutcome(result=FAILURE, status_text=["Requested"])
self.expectLogfile('log', "URL: %s\n ------ Content ------\n%s" % (url, content))
self.expectLogfile('content', content)
self.expectOutcome(result=FAILURE, status_text=["Status", "code:", '405'])
return self.runStep()

def test_header(self):
url = self.getURL("header")
self.setupStep(http.GET(url, headers={"X-Test": "True"}))
self.expectLogfile('log', "URL: %s\nStatus: 200\n ------ Content ------\nTrue" % (url, ))
self.expectOutcome(result=SUCCESS, status_text=["Requested"])
self.expectOutcome(result=SUCCESS, status_text=["Status", "code:", '200'])
return self.runStep()

0 comments on commit ee6e8bf

Please sign in to comment.