[Patchew-devel] [PATCH] rest: Add endpoint from update-project-head

Paolo Bonzini pbonzini at redhat.com
Wed May 30 16:21:16 UTC 2018


On 30/05/2018 09:21, Shubham Jain wrote:
> So I tried doing something like this. But I'm still not sure how to add
> the the series to the git

Maybe test_need_apply is the right one:

    def test_need_apply(self):
        self.cli_import("0001-simple-patch.mbox.gz")
        s = Message.objects.series_heads()[0]
        self.assertEqual(s.is_complete, True)
        self.assertEqual(s.git_result.status, Result.PENDING)
        self.do_apply()

In fact, applying the series to git is not necessary now that I think of
it.  You can use a dummy old_head and new_head, just make sure you pass
the right message-id to message_ids.

Thanks,

Paolo

> and which series should be added. 
> def test_update_project_head(self):
>         resp = self.apply_and_retrieve('some.mbox.gz',
>                                        self.p.id <http://self.p.id>,
> 'some_message_id')
>         self.api_client.login(username=self.user,
> password=self.password)        
>         resp_before = self.api_client.get(self.PROJECT_BASE + "series/"+
> "some_message_id/")
>         data = {
>                 "message_ids": [...],
>                 "old_head": "..",
>                 "new_head": "..."
>                 }
>         resp = self.api_client.post(self.PROJECT_BASE +
> "update_project_head/", data=data, content_type='application/json')
>         resp_after = self.api_client.get(self.PROJECT_BASE + "series/"+
> "some_message_id")
>         self.assertEquals(resp_before.data['is_merged'], False)
>         self.assertEquals(resp.status_code, 200)
>         self.assertEquals(resp.data['count'],1)
>         self.assertEquals(resp.data['new_head'],"..")
>         self.assertEquals(resp_after.data['is_merged'], True)
> 
> On Tue, May 29, 2018 at 5:44 PM Paolo Bonzini <pbonzini at redhat.com
> <mailto:pbonzini at redhat.com>> wrote:
> 
>     On 29/05/2018 14:07, Shubham Jain wrote:
>     > Two questions regarding the patch. I couldn't find the test case
>     in the
>     > legacy update-head and hence couldn't think of how to test this.
> 
>     You're right, the only test case for update-head uses patchew-cli to
>     invoke it.  It's in commit ea3c69962a38c77c43672190dda314c56aaa983a.
> 
>     tests/test_testing.py has some example of manipulating a git repository
>     from the tests.  See for example add_file_and_commit and
>     test_tester_project.
> 
>     Thanks,
> 
>     Paolo
> 
>     > Second, Is the data required in the POST correct? I mean, is there any
>     > other way we can feed the message ids?
> 




More information about the Patchew-devel mailing list