launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #20811
Re: [Merge] lp:~blr/launchpad/bug-1600055-configure-code-remote-username into lp:launchpad
Review: Approve
Diff comments:
>
> === modified file 'lib/lp/registry/browser/tests/test_product.py'
> --- lib/lp/registry/browser/tests/test_product.py 2015-10-01 17:32:41 +0000
> +++ lib/lp/registry/browser/tests/test_product.py 2016-07-13 02:11:25 +0000
> @@ -834,3 +837,81 @@
> with person_logged_in(owner):
> self.assertIn(public.name, browser.contents)
> self.assertIn(proprietary.name, browser.contents)
> +
> +
> +class TestProductSetBranchView(TestCaseWithFactory):
> +
> + layer = DatabaseFunctionalLayer
> +
> + def test_git_ssh_url(self):
> + project = self.factory.makeProduct()
> + with person_logged_in(project.owner):
> + view = create_initialized_view(
> + project, '+configure-code', principal=project.owner,
> + method='GET')
> + git_ssh_url = 'git+ssh://{username}@{host}/{project}'.format(
> + username=project.owner.name,
> + host=urlsplit(config.codehosting.git_ssh_root).netloc,
Should probably technically be .hostname rather than .netloc, although the result is the same.
> + project=project.name)
> + self.assertEqual(git_ssh_url, view.git_ssh_url)
> +
> +
> +class TestBrowserProductSetBranchView(BrowserTestCase):
> +
> + layer = DatabaseFunctionalLayer
> +
> + editsshkeys_tag = Tag(
> + 'edit SSH keys', 'a', text=re.compile('register an SSH key'),
> + attrs={'href': re.compile(r'/\+editsshkeys$')})
> +
> + def getBrowser(self, project, view_name=None):
> + project = removeSecurityProxy(project)
> + url = canonical_url(project, view_name=view_name)
> + return self.getUserBrowser(url, project.owner)
> +
> + def test_no_initial_git_repository(self):
> + # If a project has no default Git repository, its "Git repository"
> + # control defaults to empty.
> + project = self.factory.makeProduct()
> + browser = self.getBrowser(project, '+configure-code')
> + self.assertEqual('', browser.getControl('Git repository').value)
> +
> + def test_initial_git_repository(self):
> + # If a project has a default Git repository, its "Git repository"
> + # control defaults to the unique name of that repository.
> + project = self.factory.makeProduct()
> + repo = self.factory.makeGitRepository(target=project)
> + with person_logged_in(project.owner):
> + getUtility(IGitRepositorySet).setDefaultRepository(project, repo)
> + unique_name = repo.unique_name
> + browser = self.getBrowser(project, '+configure-code')
> + self.assertEqual(
> + unique_name, browser.getControl('Git repository').value)
> +
> + def test_link_existing_git_repository(self):
> + repo = removeSecurityProxy(self.factory.makeGitRepository(
> + target=self.factory.makeProduct()))
> + browser = self.getBrowser(repo.project, '+configure-code')
> + browser.getControl('Git', index=0).click()
> + browser.getControl('Git repository').value = repo.shortened_path
> + browser.getControl('Update').click()
> +
> + tag = Tag(
> + 'success-div', 'div', attrs={'class': 'informational message'},
> + text='Project settings updated.')
> + self.assertThat(browser.contents, HTMLContains(tag))
> +
> + def test_editsshkeys_link_if_no_keys_registered(self):
> + project = self.factory.makeProduct()
> + browser = self.getBrowser(project, '+configure-code')
> + self.assertThat(
> + browser.contents, HTMLContains(self.editsshkeys_tag))
> +
> + def test_no_editsshkeys_link_if_keys_registered(self):
> + project = self.factory.makeProduct()
> + with person_logged_in(project.owner):
> + self.factory.makeSSHKey(person=project.owner)
> + browser = self.getBrowser(project, '+configure-code')
> + self.assertThat(
> + browser.contents,
> + Not(HTMLContains(self.editsshkeys_tag)))
--
https://code.launchpad.net/~blr/launchpad/bug-1600055-configure-code-remote-username/+merge/299774
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
References