Пример #1
0
 def getDatabaseBranch(self, personName, productName, branchName):
     """Look up and return the specified branch from the database."""
     owner = Person.byName(personName)
     if productName is None:
         product = None
     else:
         product = Product.selectOneBy(name=productName)
     namespace = get_branch_namespace(owner, product)
     return namespace.getByName(branchName)
Пример #2
0
 def getDatabaseBranch(self, personName, productName, branchName):
     """Look up and return the specified branch from the database."""
     owner = Person.byName(personName)
     if productName is None:
         product = None
     else:
         product = Product.selectOneBy(name=productName)
     namespace = get_branch_namespace(owner, product)
     return namespace.getByName(branchName)
Пример #3
0
 def test_push_to_new_short_branch_alias(self):
     # We can also push branches to URLs like /+branch/firefox
     # Hack 'firefox' so we have permission to do this.
     ZopelessAppServerLayer.txn.begin()
     firefox = Product.selectOneBy(name='firefox')
     testuser = Person.selectOneBy(name='testuser')
     firefox.development_focus.owner = testuser
     ZopelessAppServerLayer.txn.commit()
     remote_url = self.getTransportURL('+branch/firefox')
     self.push(self.local_branch_path, remote_url)
     self.assertBranchesMatch(self.local_branch_path, remote_url)
Пример #4
0
 def test_push_to_new_short_branch_alias(self):
     # We can also push branches to URLs like /+branch/firefox
     # Hack 'firefox' so we have permission to do this.
     ZopelessAppServerLayer.txn.begin()
     firefox = Product.selectOneBy(name='firefox')
     testuser = Person.selectOneBy(name='testuser')
     firefox.development_focus.owner = testuser
     ZopelessAppServerLayer.txn.commit()
     remote_url = self.getTransportURL('+branch/firefox')
     self.push(self.local_branch_path, remote_url)
     self.assertBranchesMatch(self.local_branch_path, remote_url)
Пример #5
0
def _get_locals():
    if len(sys.argv) > 1:
        dbuser = sys.argv[1]
    else:
        dbuser = None
    dbconfig.override(dbuser=dbuser)
    execute_zcml_for_scripts()
    readline.parse_and_bind('tab: complete')
    # Mimic the real interactive interpreter's loading of any
    # $PYTHONSTARTUP file.
    startup = os.environ.get('PYTHONSTARTUP')
    if startup:
        execfile(startup)
    store = IMasterStore(Person)

    if dbuser == 'launchpad':
        # Create a few variables "in case they come in handy."
        # Do we really use these?  Are they worth carrying around?
        d = Distribution.get(1)
        p = Person.get(1)
        ds = DistroSeries.get(1)
        prod = Product.get(1)
        proj = ProjectGroup.get(1)
        b2 = Bug.get(2)
        b1 = Bug.get(1)
        s = Specification.get(1)
        q = Question.get(1)
        # Silence unused name warnings
        d, p, ds, prod, proj, b2, b1, s, q

    # Having a factory instance is handy.
    factory = LaunchpadObjectFactory()

    def browser_open(obj, *args, **kwargs):
        """Open a (possibly newly-created) object's view in a web browser.

        Accepts the same parameters as canonical_url.

        Performs a commit before invoking the browser, so
        "browser_open(factory.makeFoo())" works.
        """
        transaction.commit()
        webbrowser.open(canonical_url(obj, *args, **kwargs))

    # Silence unused name warnings
    factory, store

    res = {}
    res.update(locals())
    res.update(globals())
    del res['_get_locals']
    return res
Пример #6
0
def _get_locals():
    if len(sys.argv) > 1:
        dbuser = sys.argv[1]
    else:
        dbuser = None
    dbconfig.override(dbuser=dbuser)
    execute_zcml_for_scripts()
    readline.parse_and_bind('tab: complete')
    # Mimic the real interactive interpreter's loading of any
    # $PYTHONSTARTUP file.
    startup = os.environ.get('PYTHONSTARTUP')
    if startup:
        execfile(startup)
    store = IMasterStore(Person)

    if dbuser == 'launchpad':
        # Create a few variables "in case they come in handy."
        # Do we really use these?  Are they worth carrying around?
        d = Distribution.get(1)
        p = Person.get(1)
        ds = DistroSeries.get(1)
        prod = Product.get(1)
        proj = ProjectGroup.get(1)
        b2 = Bug.get(2)
        b1 = Bug.get(1)
        s = Specification.get(1)
        q = Question.get(1)
        # Silence unused name warnings
        d, p, ds, prod, proj, b2, b1, s, q

    # Having a factory instance is handy.
    factory = LaunchpadObjectFactory()

    def browser_open(obj, *args, **kwargs):
        """Open a (possibly newly-created) object's view in a web browser.

        Accepts the same parameters as canonical_url.

        Performs a commit before invoking the browser, so
        "browser_open(factory.makeFoo())" works.
        """
        transaction.commit()
        webbrowser.open(canonical_url(obj, *args, **kwargs))

    # Silence unused name warnings
    factory, store

    res = {}
    res.update(locals())
    res.update(globals())
    del res['_get_locals']
    return res
Пример #7
0
    def test_cant_access_private_branch(self):
        # Trying to get information about a private branch should fail as if
        # the branch doesn't exist.

        # 'salgado' is a member of landscape-developers.
        salgado = Person.selectOneBy(name='salgado')
        landscape_dev = Person.selectOneBy(name='landscape-developers')
        self.assertTrue(
            salgado.inTeam(landscape_dev),
            "salgado should be a member of landscape-developers, but isn't.")

        # Make a private branch.
        branch_url = self.createBazaarBranch('landscape-developers',
                                             'landscape',
                                             'some-branch',
                                             creator='salgado')
        # Sanity checking that the branch is actually there. We don't care
        # about the result, only that the call succeeds.
        self.getLastRevision(branch_url)

        # Check that testuser can't access the branch.
        remote_url = self.getTransportURL(
            '~landscape-developers/landscape/some-branch')
        self.assertNotBranch(remote_url)
Пример #8
0
    def test_cant_access_private_branch(self):
        # Trying to get information about a private branch should fail as if
        # the branch doesn't exist.

        # 'salgado' is a member of landscape-developers.
        salgado = Person.selectOneBy(name='salgado')
        landscape_dev = Person.selectOneBy(
            name='landscape-developers')
        self.assertTrue(
            salgado.inTeam(landscape_dev),
            "salgado should be a member of landscape-developers, but isn't.")

        # Make a private branch.
        branch_url = self.createBazaarBranch(
            'landscape-developers', 'landscape', 'some-branch',
            creator='salgado')
        # Sanity checking that the branch is actually there. We don't care
        # about the result, only that the call succeeds.
        self.getLastRevision(branch_url)

        # Check that testuser can't access the branch.
        remote_url = self.getTransportURL(
            '~landscape-developers/landscape/some-branch')
        self.assertNotBranch(remote_url)
Пример #9
0
    def makeDatabaseBranch(self, owner_name, product_name, branch_name,
                           branch_type=BranchType.HOSTED):
        """Create a new branch in the database."""
        owner = Person.selectOneBy(name=owner_name)
        if product_name == '+junk':
            product = None
        else:
            product = Product.selectOneBy(name=product_name)
        if branch_type == BranchType.MIRRORED:
            url = 'http://example.com'
        else:
            url = None

        namespace = get_branch_namespace(owner, product)
        return namespace.createBranch(
            branch_type=branch_type, name=branch_name, registrant=owner,
            url=url)
Пример #10
0
 def makePerson(self, account):
     return self.store.add(
         Person(name='acc%d' % account.id,
                account=account,
                displayname='Displayname',
                creation_rationale=PersonCreationRationale.UNKNOWN))