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
1=== modified file 'lib/lp/code/doc/branch-karma.txt'
2--- lib/lp/code/doc/branch-karma.txt 2010-03-26 20:35:31 +0000
3+++ lib/lp/code/doc/branch-karma.txt 2010-05-11 03:25:36 +0000
4@@ -48,8 +48,9 @@
5
6 You get karma for linking a bug to a branch.
7
8- >>> bug = factory.makeBug(product=fooix)
9- Karma added: action=bugcreated, product=fooix, person=person-name11
10+ >>> reporter = factory.makePerson(name='reporter')
11+ >>> bug = factory.makeBug(product=fooix, owner=reporter)
12+ Karma added: action=bugcreated, product=fooix, person=reporter
13 >>> branch_link = bug.linkBranch(branch, eric)
14 Karma added: action=bugbranchcreated, product=fooix, person=eric
15
16
17=== modified file 'lib/lp/code/stories/branches/xx-branch-index.txt'
18--- lib/lp/code/stories/branches/xx-branch-index.txt 2010-02-17 07:44:48 +0000
19+++ lib/lp/code/stories/branches/xx-branch-index.txt 2010-05-11 03:25:36 +0000
20@@ -13,17 +13,14 @@
21
22 Modifying/creating test data for this test case.
23
24- >>> login('foo.bar@canonical.com')
25- >>> branch = getUtility(IBranchLookup).getByUniqueName(
26- ... '~name12/+junk/junk.dev')
27- >>> factory.makeRevisionsForBranch(branch, count=5)
28- >>> sample_person = getUtility(IPersonSet).getByName('name12')
29- >>> anonymous_product = factory.makeProduct(
30- ... name='anonymous-product', owner=sample_person)
31- >>> anonymous_branch = factory.makeProductBranch(
32- ... name='anonymous-branch', product=anonymous_product,
33- ... owner=sample_person)
34- >>> anonymous_product.setAliases(['alias-for-product'])
35+ >>> login('admin@canonical.com')
36+ >>> eric = factory.makePerson(name='eric', email='eric@example.com')
37+ >>> fooix = factory.makeProduct(name='fooix', owner=eric)
38+ >>> branch = factory.makeProductBranch(
39+ ... name='trunk', product=fooix, owner=eric)
40+ >>> fooix.setAliases(['fooey'])
41+ >>> factory.makeRevisionsForBranch(
42+ ... branch, count=5, author='eric@example.com')
43 >>> logout()
44
45
46@@ -34,21 +31,19 @@
47 name or any of its aliases. In case an alias is used, the user is redirected
48 to the branch's canonical URL -- the one which uses the product name.
49
50- >>> anon_browser.open('http://code.launchpad.dev/~name12/anonymous-product'
51- ... '/anonymous-branch')
52- >>> anon_browser.url
53- 'http://code.launchpad.dev/~name12/anonymous-product/anonymous-branch'
54- >>> anon_browser.open('http://code.launchpad.dev/~name12/alias-for-product'
55- ... '/anonymous-branch')
56- >>> anon_browser.url
57- 'http://code.launchpad.dev/~name12/anonymous-product/anonymous-branch'
58+ >>> anon_browser.open('http://code.launchpad.dev/~eric/fooix/trunk')
59+ >>> anon_browser.url
60+ 'http://code.launchpad.dev/~eric/fooix/trunk'
61+ >>> anon_browser.open('http://code.launchpad.dev/~eric/fooey/trunk')
62+ >>> anon_browser.url
63+ 'http://code.launchpad.dev/~eric/fooix/trunk'
64
65
66 == Recent Revisions ==
67
68 We display the recent revisions of a branch if it has been scanned.
69
70- >>> user_browser.open('http://code.launchpad.dev/~name12/+junk/junk.dev')
71+ >>> user_browser.open('http://code.launchpad.dev/~eric/fooix/trunk')
72 >>> assert find_tag_by_id(user_browser.contents, 'merge-summary') is None
73 >>> revisions = find_tag_by_id(user_browser.contents, 'recent-revisions')
74 >>> def print_merge_links(browser):
75@@ -75,24 +70,18 @@
76 ... print extract_text(revision).encode('ascii')
77
78 >>> print_revisions(user_browser)
79- 11. By author1 on 2007-01-05
80- 10. By author1 on 2007-01-04
81- 9. By author1 on 2007-01-03
82- 8. By author1 on 2007-01-02
83- 7. By author1 on 2007-01-01
84- 6. By foo <foo@localhost> on 2005-10-31
85- 5. By foo <foo@localhost> on 2005-10-31
86- 4. By bar@localhost on 2005-10-31
87- 3. By Sample Person on 2005-10-31
88- 2. By Sample Person on 2005-10-31
89+ 5. By Eric on 2007-01-05
90+ 4. By Eric on 2007-01-04
91+ 3. By Eric on 2007-01-03
92+ 2. By Eric on 2007-01-02
93+ 1. By Eric on 2007-01-01
94
95-Each of the revision numbers are now anchors to codebrowse (for public
96-branches).
97+Each of the revision numbers are anchors to codebrowse.
98
99 >>> revision = find_tags_by_class(
100 ... user_browser.contents, 'revision-details', only_first=True)
101 >>> print revision.a
102- <a href="http://bazaar.launchpad.dev/~name12/+junk/junk.dev/revision/11">11</a>
103+ <a href="http://bazaar.launchpad.dev/~eric/fooix/trunk/revision/5">5</a>
104
105
106 === Commit messages ===
107@@ -104,13 +93,13 @@
108 >>> commit_messages = find_tags_by_class(
109 ... browser.contents, 'revision-comment')
110 >>> print commit_messages[0].p.renderContents()
111- log-body11
112+ fix bug in bar
113
114
115 When a commit message refers to a bug using the form "bug <bugnumber>", a link
116 to that bug is created.
117
118- >>> print commit_messages[8].p.renderContents()
119+ >>> print commit_messages[3].p.renderContents()
120 fix <a ...>bug 1</a>
121
122
123@@ -285,21 +274,11 @@
124 Recent revisions
125 This branch is empty.
126
127-Sample Person's junk branch has some revisions, so the revisions are linked to
128-the revisions are linked to the code.
129-
130- >>> browser.open(
131- ... 'http://code.launchpad.dev/~name12/+junk/junk.dev')
132- >>> print extract_text(find_tag_by_id(
133- ... browser.contents, "recent-revisions").dl)
134- 11. By author1 on ...
135- 6. By foo... fix bug in bar...
136- >>> print browser.getLink('11').url
137- http://bazaar.launchpad.dev/~name12/+junk/junk.dev/revision/11
138-
139 In addition, there is a "All revisions" link that links to the
140 changelog view in codebrowse.
141
142+ >>> browser.open(
143+ ... 'http://code.launchpad.dev/~name12/+junk/junk.dev')
144 >>> print browser.getLink('All revisions').url
145 http://bazaar.launchpad.dev/~name12/+junk/junk.dev/changes
146