Merge lp:~thumper/launchpad/fix-factory-ids-in-tests into lp:launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 10860
Proposed branch: lp:~thumper/launchpad/fix-factory-ids-in-tests
Merge into: lp:launchpad
Diff against target: 145 lines (+29/-49)
2 files modified
lib/lp/code/doc/branch-karma.txt (+3/-2)
lib/lp/code/stories/branches/xx-branch-index.txt (+26/-47)
To merge this branch: bzr merge lp:~thumper/launchpad/fix-factory-ids-in-tests
Reviewer Review Type Date Requested Status
Paul Hummer (community) code Approve
Review via email: mp+25037@code.launchpad.net

Commit message

Fixes the code tests so they don't depend on factory generated values.

Description of the change

Fixing the tests so they don't depend on factory generated values.

xx-branch-index
branch-karma.txt

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

Land it. Land it now.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/doc/branch-karma.txt'
--- lib/lp/code/doc/branch-karma.txt 2010-03-26 20:35:31 +0000
+++ lib/lp/code/doc/branch-karma.txt 2010-05-11 03:25:36 +0000
@@ -48,8 +48,9 @@
4848
49You get karma for linking a bug to a branch.49You get karma for linking a bug to a branch.
5050
51 >>> bug = factory.makeBug(product=fooix)51 >>> reporter = factory.makePerson(name='reporter')
52 Karma added: action=bugcreated, product=fooix, person=person-name1152 >>> bug = factory.makeBug(product=fooix, owner=reporter)
53 Karma added: action=bugcreated, product=fooix, person=reporter
53 >>> branch_link = bug.linkBranch(branch, eric)54 >>> branch_link = bug.linkBranch(branch, eric)
54 Karma added: action=bugbranchcreated, product=fooix, person=eric55 Karma added: action=bugbranchcreated, product=fooix, person=eric
5556
5657
=== modified file 'lib/lp/code/stories/branches/xx-branch-index.txt'
--- lib/lp/code/stories/branches/xx-branch-index.txt 2010-02-17 07:44:48 +0000
+++ lib/lp/code/stories/branches/xx-branch-index.txt 2010-05-11 03:25:36 +0000
@@ -13,17 +13,14 @@
1313
14Modifying/creating test data for this test case.14Modifying/creating test data for this test case.
1515
16 >>> login('foo.bar@canonical.com')16 >>> login('admin@canonical.com')
17 >>> branch = getUtility(IBranchLookup).getByUniqueName(17 >>> eric = factory.makePerson(name='eric', email='eric@example.com')
18 ... '~name12/+junk/junk.dev')18 >>> fooix = factory.makeProduct(name='fooix', owner=eric)
19 >>> factory.makeRevisionsForBranch(branch, count=5)19 >>> branch = factory.makeProductBranch(
20 >>> sample_person = getUtility(IPersonSet).getByName('name12')20 ... name='trunk', product=fooix, owner=eric)
21 >>> anonymous_product = factory.makeProduct(21 >>> fooix.setAliases(['fooey'])
22 ... name='anonymous-product', owner=sample_person)22 >>> factory.makeRevisionsForBranch(
23 >>> anonymous_branch = factory.makeProductBranch(23 ... branch, count=5, author='eric@example.com')
24 ... name='anonymous-branch', product=anonymous_product,
25 ... owner=sample_person)
26 >>> anonymous_product.setAliases(['alias-for-product'])
27 >>> logout()24 >>> logout()
2825
2926
@@ -34,21 +31,19 @@
34name or any of its aliases. In case an alias is used, the user is redirected31name or any of its aliases. In case an alias is used, the user is redirected
35to the branch's canonical URL -- the one which uses the product name.32to the branch's canonical URL -- the one which uses the product name.
3633
37 >>> anon_browser.open('http://code.launchpad.dev/~name12/anonymous-product'34 >>> anon_browser.open('http://code.launchpad.dev/~eric/fooix/trunk')
38 ... '/anonymous-branch')35 >>> anon_browser.url
39 >>> anon_browser.url36 'http://code.launchpad.dev/~eric/fooix/trunk'
40 'http://code.launchpad.dev/~name12/anonymous-product/anonymous-branch'37 >>> anon_browser.open('http://code.launchpad.dev/~eric/fooey/trunk')
41 >>> anon_browser.open('http://code.launchpad.dev/~name12/alias-for-product'38 >>> anon_browser.url
42 ... '/anonymous-branch')39 'http://code.launchpad.dev/~eric/fooix/trunk'
43 >>> anon_browser.url
44 'http://code.launchpad.dev/~name12/anonymous-product/anonymous-branch'
4540
4641
47== Recent Revisions ==42== Recent Revisions ==
4843
49We display the recent revisions of a branch if it has been scanned.44We display the recent revisions of a branch if it has been scanned.
5045
51 >>> user_browser.open('http://code.launchpad.dev/~name12/+junk/junk.dev')46 >>> user_browser.open('http://code.launchpad.dev/~eric/fooix/trunk')
52 >>> assert find_tag_by_id(user_browser.contents, 'merge-summary') is None47 >>> assert find_tag_by_id(user_browser.contents, 'merge-summary') is None
53 >>> revisions = find_tag_by_id(user_browser.contents, 'recent-revisions')48 >>> revisions = find_tag_by_id(user_browser.contents, 'recent-revisions')
54 >>> def print_merge_links(browser):49 >>> def print_merge_links(browser):
@@ -75,24 +70,18 @@
75 ... print extract_text(revision).encode('ascii')70 ... print extract_text(revision).encode('ascii')
7671
77 >>> print_revisions(user_browser)72 >>> print_revisions(user_browser)
78 11. By author1 on 2007-01-0573 5. By Eric on 2007-01-05
79 10. By author1 on 2007-01-0474 4. By Eric on 2007-01-04
80 9. By author1 on 2007-01-0375 3. By Eric on 2007-01-03
81 8. By author1 on 2007-01-0276 2. By Eric on 2007-01-02
82 7. By author1 on 2007-01-0177 1. By Eric on 2007-01-01
83 6. By foo <foo@localhost> on 2005-10-31
84 5. By foo <foo@localhost> on 2005-10-31
85 4. By bar@localhost on 2005-10-31
86 3. By Sample Person on 2005-10-31
87 2. By Sample Person on 2005-10-31
8878
89Each of the revision numbers are now anchors to codebrowse (for public79Each of the revision numbers are anchors to codebrowse.
90branches).
9180
92 >>> revision = find_tags_by_class(81 >>> revision = find_tags_by_class(
93 ... user_browser.contents, 'revision-details', only_first=True)82 ... user_browser.contents, 'revision-details', only_first=True)
94 >>> print revision.a83 >>> print revision.a
95 <a href="http://bazaar.launchpad.dev/~name12/+junk/junk.dev/revision/11">11</a>84 <a href="http://bazaar.launchpad.dev/~eric/fooix/trunk/revision/5">5</a>
9685
9786
98=== Commit messages ===87=== Commit messages ===
@@ -104,13 +93,13 @@
104 >>> commit_messages = find_tags_by_class(93 >>> commit_messages = find_tags_by_class(
105 ... browser.contents, 'revision-comment')94 ... browser.contents, 'revision-comment')
106 >>> print commit_messages[0].p.renderContents()95 >>> print commit_messages[0].p.renderContents()
107 log-body1196 fix bug in bar
10897
10998
110When a commit message refers to a bug using the form "bug <bugnumber>", a link99When a commit message refers to a bug using the form "bug <bugnumber>", a link
111to that bug is created.100to that bug is created.
112101
113 >>> print commit_messages[8].p.renderContents()102 >>> print commit_messages[3].p.renderContents()
114 fix <a ...>bug 1</a>103 fix <a ...>bug 1</a>
115104
116105
@@ -285,21 +274,11 @@
285 Recent revisions274 Recent revisions
286 This branch is empty.275 This branch is empty.
287276
288Sample Person's junk branch has some revisions, so the revisions are linked to
289the revisions are linked to the code.
290
291 >>> browser.open(
292 ... 'http://code.launchpad.dev/~name12/+junk/junk.dev')
293 >>> print extract_text(find_tag_by_id(
294 ... browser.contents, "recent-revisions").dl)
295 11. By author1 on ...
296 6. By foo... fix bug in bar...
297 >>> print browser.getLink('11').url
298 http://bazaar.launchpad.dev/~name12/+junk/junk.dev/revision/11
299
300In addition, there is a "All revisions" link that links to the277In addition, there is a "All revisions" link that links to the
301changelog view in codebrowse.278changelog view in codebrowse.
302279
280 >>> browser.open(
281 ... 'http://code.launchpad.dev/~name12/+junk/junk.dev')
303 >>> print browser.getLink('All revisions').url282 >>> print browser.getLink('All revisions').url
304 http://bazaar.launchpad.dev/~name12/+junk/junk.dev/changes283 http://bazaar.launchpad.dev/~name12/+junk/junk.dev/changes
305284