#141 bugimg endpoint: show info if bug is closed
Merged 3 years ago by lbrabec. Opened 3 years ago by lbrabec.

@@ -179,6 +179,7 @@ 

      return bugtypes

  

  _UNKNOWN_BUG_SVG_TEXT = _svg_response_text(["unknown bug"])

+ _BUG_CLOSED = "BUG CLOSED"

  

  @api_v0.route('/bugimg/<int:bug_id>')

  def bug_image(bug_id):
@@ -187,6 +188,10 @@ 

          return SVGResponse(_UNKNOWN_BUG_SVG_TEXT)

      else:

          info_all = []

+         # since the filtering is based on bugid, all the bug entries have the same status

+         # so we can use the first one

+         if bugs[0].status == "CLOSED":

+             info_all.append(_BUG_CLOSED)

          for bug in bugs:

              milestone_info = "%s: " % bug.milestone.name

              bugtypes = _get_bugtypes(bug)

file modified
+18 -1
@@ -16,7 +16,7 @@ 

  from testing.test_controllers import add_release, add_milestone, \

      add_bug, add_update

  from blockerbugs.controllers.api import errors

- from blockerbugs.controllers.api.api import _get_bugtypes, _UNKNOWN_BUG_SVG_TEXT

+ from blockerbugs.controllers.api.api import _get_bugtypes, _UNKNOWN_BUG_SVG_TEXT, _BUG_CLOSED

  

  

  class TestRestAPI(object):
@@ -35,6 +35,7 @@ 

                                         '99-beta')

          bug1 = add_bug(9000, 'testbug1', cls.milestone)

          bug1.accepted_fe = True

+         bug1.status = 'CLOSED'

          bug2 = add_bug(9002, 'testbug2', cls.milestone)

          bug2.accepted_blocker = False

          bug2.proposed_fe = True
@@ -163,3 +164,19 @@ 

  

          assert self.milestone.name not in data

          assert _UNKNOWN_BUG_SVG_TEXT in data

+ 

+     def test_get_bugimg_open_bug(self):

+         url = '/api/v0/bugimg/9002'

+         resp = self.client.get(url)

+         assert resp.status_code == httplib.OK

+         data = str(resp.data)

+ 

+         assert _BUG_CLOSED not in data

+ 

+     def test_get_bugimg_closed_bug(self):

+         url = '/api/v0/bugimg/9000'

+         resp = self.client.get(url)

+         assert resp.status_code == httplib.OK

+         data = str(resp.data)

+ 

+         assert _BUG_CLOSED in data