~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/model/tests/test_branchlookup.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-04-20 03:16:35 UTC
  • mfrom: (12707.7.7 stack-on-branch-id-alias)
  • Revision ID: launchpad@pqm.canonical.com-20110420031635-39sx3wjbtxbm9l5j
[r=bac][bug=377519] Change the default stacking location to use the
 branch id alias.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    ILinkedBranchTraverser,
26
26
    )
27
27
from lp.code.interfaces.branchnamespace import get_branch_namespace
28
 
from lp.code.interfaces.codehosting import BRANCH_ID_ALIAS_PREFIX
 
28
from lp.code.interfaces.codehosting import (
 
29
    branch_id_alias,
 
30
    BRANCH_ID_ALIAS_PREFIX,
 
31
    )
29
32
from lp.code.interfaces.linkedbranch import ICanHasLinkedBranch
30
33
from lp.registry.errors import (
31
34
    NoSuchDistroSeries,
137
140
        owner = self.factory.makePerson()
138
141
        branch = self.factory.makeAnyBranch(owner=owner, private=True)
139
142
        with person_logged_in(owner):
140
 
            path = '/%s/%s' % (BRANCH_ID_ALIAS_PREFIX, branch.id)
 
143
            path = branch_id_alias(branch)
141
144
        result = self.branch_set.getIdAndTrailingPath(path)
142
145
        self.assertEqual((None, None), result)
143
146
 
144
147
    def test_branch_id_alias_public(self):
145
148
        # Public branches can be accessed.
146
149
        branch = self.factory.makeAnyBranch()
147
 
        path = '/%s/%s' % (BRANCH_ID_ALIAS_PREFIX, branch.id)
 
150
        path = branch_id_alias(branch)
148
151
        result = self.branch_set.getIdAndTrailingPath(path)
149
152
        self.assertEqual((branch.id, ''), result)
150
153
 
151
154
    def test_branch_id_alias_public_slash(self):
152
155
        # A trailing slash is returned as the extra path.
153
156
        branch = self.factory.makeAnyBranch()
154
 
        path = '/%s/%s/' % (BRANCH_ID_ALIAS_PREFIX, branch.id)
 
157
        path = '%s/' % branch_id_alias(branch)
155
158
        result = self.branch_set.getIdAndTrailingPath(path)
156
159
        self.assertEqual((branch.id, '/'), result)
157
160
 
158
161
    def test_branch_id_alias_public_with_path(self):
159
162
        # All the path after the number is returned as the trailing path.
160
163
        branch = self.factory.makeAnyBranch()
161
 
        path = '/%s/%s/foo' % (BRANCH_ID_ALIAS_PREFIX, branch.id)
 
164
        path = '%s/foo' % branch_id_alias(branch)
162
165
        result = self.branch_set.getIdAndTrailingPath(path)
163
166
        self.assertEqual((branch.id, '/foo'), result)
164
167