← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] lp:~cjwatson/launchpad/git-mp-commits-diff into lp:launchpad

 

Review: Approve code



Diff comments:

> 
> === modified file 'lib/lp/code/browser/tests/test_gitrepository.py'
> --- lib/lp/code/browser/tests/test_gitrepository.py	2015-10-19 10:56:16 +0000
> +++ lib/lp/code/browser/tests/test_gitrepository.py	2016-05-14 11:04:41 +0000
> @@ -756,6 +756,32 @@
>          self.assertShownTypes([InformationType.PROPRIETARY], repository)
>  
>  
> +class TestGitRepositoryDiffView(BrowserTestCase):
> +
> +    layer = DatabaseFunctionalLayer
> +
> +    def test_render(self):
> +        hosting_client = FakeMethod()
> +        diff = u"A fake diff\n"
> +        hosting_client.getDiff = FakeMethod(result={"patch": diff})
> +        self.useFixture(ZopeUtilityFixture(hosting_client, IGitHostingClient))
> +        person = self.factory.makePerson()
> +        repository = self.factory.makeGitRepository(owner=person)
> +        browser = self.getUserBrowser(
> +            canonical_url(repository) + "/+diff/0123456/0123456^")
> +        with person_logged_in(person):
> +            self.assertEqual(
> +                [((repository.getInternalPath(), "0123456^", "0123456"), {})],
> +                hosting_client.getDiff.calls)
> +        self.assertEqual(
> +            'text/x-patch;charset=UTF-8', browser.headers["Content-Type"])
> +        self.assertEqual(str(len(diff)), browser.headers["Content-Length"])
> +        self.assertEqual(
> +            "attachment; filename=0123456^_0123456.diff",
> +            browser.headers["Content-Disposition"])
> +        self.assertEqual("A fake diff\n", browser.contents)

I'd quite like a security test here; we're relying heavily on security proxies to save us, as the traversal is not explicitly protected.

> +
> +
>  class TestGitRepositoryDeletionView(BrowserTestCase):
>  
>      layer = DatabaseFunctionalLayer


-- 
https://code.launchpad.net/~cjwatson/launchpad/git-mp-commits-diff/+merge/294704
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.


References