#2124 API: allow to edit issue milestone
Merged by pingou. Opened by mbasti.
mbasti/pagure milestone-api  into  master

Download 2124.patch

I tried to create a API for issue milestone, but I somehow failed. My tests are failing (got ecode 200 expected 400) and I'm lost in that code. I need a guidance what I did wrong (I used state_change API as template)

New API endpoint has been added, see specification bellow

Change issue milestone
-------------------
Change the milestone of an issue.
::
     POST /api/0/<repo>/issue/<issue id>/milestone
     POST /api/0/<namespace>/<repo>/issue/<issue id>/milestone
::
     POST /api/0/fork/<username>/<repo>/issue/<issue id>/milestone
     POST /api/0/fork/<username>/<namespace>/<repo>/issue/<issue id>/milestone
Input
^^^^^
+----------------- +---------+--------------+------------------------+
| Key              | Type    | Optionality  | Description            |
+==================+=========+==============+========================+
| ``milestone``    | string  | Mandatory    | The new milestone of   |
|                  |         |              | the issue, can be any  |
|                  |         |              | of defined milestones  |
|                  |         |              | or empty to unset the  |
|                  |         |              | milestone              |
+----------------- +---------+--------------+------------------------+
Sample response
^^^^^^^^^^^^^^^
::
    {
      "message": "Successfully edited issue #1"
    }

Fixes: https://pagure.io/pagure/issue/2111

This is why your test is failing, since milestone is optional, not specifying one won't raise an error

Since no milestone is valid (since it's optional), this is a valid request, thus a 200 returned

Didn't you want to test the milestone here (rather than the status)?

Maybe you could add here the three lines ensuring that the milestone was added?

This isn't a valid request because the project does not have any milestone saved, so milestone-1-0 isn't in the list of allowed milestone

Saw my patch? :)

No, I saw just inline comments.

I'm quite busy now I will return to this later.

Hm looks like I forgot to submit my comment, I was pointing to these two patches that make the tests pass: https://paste.fedoraproject.org/paste/geoiPRl0WWe2GgtbvkCmQl5M1UNdIGYhyRLivL9gydE=/

Thank you very much for help. I added another testcase, I can merge it into on commit when ACKed.

I still think that this should be handled as invalid input for milestone endpoint.

data = {
    'title': 'test issue',
}

It is clear in API specification that only milestone keyword is allowed in json

rebased

This should be probably mandratory, because in specification I wrote "Mandratory" :)

It is clear in API specification that only milestone keyword is allowed in json

Basically what it says is that only the milestone keyword is supported, but just like for any HTTP request, you can provide as many keywords as you want, the server will just not do anything with them.

For example: https://pagure.io/pagure/pull-request/2124?hello=world&Hithere=mbasti&Love=Fedora&pagure=notsobad totally valid, but pagure won't do anything with them :)

If you make it mandatory, it will not be possible to reset the milestone field, so we may want to adjust the doc rather than this one here :)

Just for testing, you can also try to make data entirely empty, this should have the same effect :)

This is looking good, I think we can just adjust the documentation (from mandatory to optional so we support resetting the milestone) and merge.

I don't mind keeping this 5 commits if since it shows the history but I don't mind if you prefer to squash them, up to you :)

rebased

Updated, testcase added

I merged commits to make this atomic to save people's time with git blame

Let's get it in! :)

Pull-Request has been merged by pingou

Metadata