Merge lp:~stevenk/launchpad/switch-ifp-to-unittests into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Graham Binns on 2010-08-12 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 11343 |
| Proposed branch: | lp:~stevenk/launchpad/switch-ifp-to-unittests |
| Merge into: | lp:launchpad |
| Prerequisite: | lp:~stevenk/launchpad/move-ifp-from-idistroseries |
| Diff against target: |
383 lines (+183/-191) 2 files modified
lib/lp/soyuz/doc/initialise-from-parent.txt (+0/-191) lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py (+183/-0) |
| To merge this branch: | bzr merge lp:~stevenk/launchpad/switch-ifp-to-unittests |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Graham Binns (community) | 2010-08-09 | Abstain on 2010-08-12 | |
| Michael Nelson (community) | Approve on 2010-08-12 | ||
|
Review via email:
|
|||
Commit Message
Drop the doctest for scripts/
Description of the Change
This branch drops the doctest for initialise-
| Michael Nelson (michael.nelson) wrote : | # |
Hi Steven,
It's great to see the doctest being replaced!
In addition to the method comment mentioned by gmb, I'd also be keen to see all the test_failure_* methods be a bit more specific... the easiest way to do this might be to use self.assertRais
There is generally a lot of info in the doctest which is currently removed... it'd be great to include all the pertinent bits (imagine you knew nothing about soyuz and were looking at this test).
I can't see anything missing from the conversion... perhaps one or two things could be removed (see below). Also, regarding the length of test_initialise,
=== added file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -0,0 +1,144 @@
<snip>
+
+ def test_initialise
From here...
+ foobuntu = self._create_
+ self._set_
+ transaction.
+ ids = InitialiseDistr
+ ids.check()
+ ids.initialise()
to here could be extracted into self._initialis
and then from here:
+ hoary_pmount_pubs = self.hoary.
+ foobuntu_
+ self.assertEqua
+ hoary_i386_
+ 'pmount')
+ foobuntu_
+ 'pmount')
+ self.assertEqual(
+ len(hoary_
+ pmount_binrel = (
+ foobuntu[
+ 'pmount'
+ self.assertEqua
+ self.assertEqua
+ self.assertEqual(
+ pmount_
+ u'i386 build of pmount 0.1-1 in ubuntu hoary RELEASE')
+ pmount_srcrel = pmount_
+ self.assertEqua
+ foobuntu_pmount = pmount_
+ foobuntu['i386'], foobuntu.
+ hoary_pmount = pmount_
+ self.hoary['i386'], self.hoary.
+ self.assertEqua
+ pmount_source = self.hoary.
+ 'pmount'
+ self.assertEqual(
+ pmount_
+ '"pmount" 0.1-2 source package in The Hoary Hedgehog Release')
+ pmount_source = foobuntu.
+ self.assertEqual(
+ pmount_
+ '"pmount" 0.1-2 source package in The Foobuntu')
...to here into self.assertDist
| Michael Nelson (michael.nelson) wrote : | # |
Hi Steve,
As per our IRC conv., unless there's a reason for not creating a custom assertion such as assertDistroSer
Also, this method (whether it is renamed or not) should definitely not be creating builds... it should only be checking/asserting things. That's why I really think it should be a separate test (see comment above where it's identified).
And lastly, you didn't comment on the _initiale_
{{{
12:15 < noodles> StevenK: I assumed when you said earlier that it adds nothing to the test run, that you'd isolated the positive tests, but the diff on the MP still only has test_initialize? Also any reason for not calling _check_distroseries assertDistroSer
12:19 < jelmer> bigjools: While I'm changing the BinaryPackageRe
12:19 < bigjools> jelmer: what's that for?
12:19 < jelmer> bigjools: I have to touch the code that fills it in, and it would help for bug 319196 and bug 602385
12:19 < edbot> Bug #319196: On the source+ page, provide external links <https:/
12:19 < edbot> Bug #602385: Allow SPs to register an upstream project <https:/
12:20 < bigjools> jelmer: that would need to be on SourcePackageRe
12:20 < bigjools> wouldn't, even
12:22 < StevenK> noodles: It shouldn't ...
12:22 < StevenK> noodles: Both test_initialise() and test_script() call self._check_
12:22 < bigjools> jelmer: also, I'm not sure about that first bug any more, I think we should do it through packaging links
12:22 < bigjools> as per the 2nd bug
12:23 < bigjools> it might be worth talking to Curtis
12:23 < noodles> StevenK: yes, but they both use it like an assertion, so why not a custom assertion as above?
12:23 < jelmer> bigjools: It would need to be on both spr and bpr I guess, since its in both their control fields
12:23 < jelmer> bigjools: I'll ask him, thanks
12:24 < StevenK> noodles: I can rename the method if you wish, but the intent is clear
12:24 < bigjools> jelmer: I can't see the actual use for it in LP if it's on BPR though
12:24 < noodles> StevenK: I don't mind... I was just wondering if there was a reason for not using standard unit-test conventions?
12:24 < StevenK> noodles: I was trying to get away with changing as little code as possible
12:25 < StevenK> It worked, too.
}}}
| Robert Collins (lifeless) wrote : | # |
@Michael, re custom assertions - have you seen the matcher stuff that
James Westby has been emailing about on the dev list? I'm biased ;),
but I think its really nice and cleaner than custom assertions.
-Rob
| Michael Nelson (michael.nelson) wrote : | # |
> @Michael, re custom assertions - have you seen the matcher stuff that
> James Westby has been emailing about on the dev list? I'm biased ;),
> but I think its really nice and cleaner than custom assertions.
>
> -Rob
Yeah I did... they do look great :) I'd be happy if StevenK wanted to use them, but didn't want to request even more changes. I'll leave that up to StevenK.
| Michael Nelson (michael.nelson) wrote : | # |
Thanks again Steven. It looks good now... there are just some inconsistencies in the comments which I've highlighted with a diff (to save confusion):
http://
With those fixed up as you see fit, r=me.
| Graham Binns (gmb) wrote : | # |
I think Michael's review is more than comprehensive enough to cover my original concerns.

Hi Steve,
So, your new tests look okay, though I'd like to get a second opinion on whether they completely replace the existing doctests since I find the doctests quite torturous to read.
However, the new tests are sorely in need of comments. Firstly, each test_ method should have a comment or docstring (I prefer comments for tests, FTR) explaining what's being tested, in the form:
def test_frobnob_ goes_boing( self):
# The frobnob will go boing if pushed.
Secondly, I can't tell (because there are no comments to tell me) whether test_initialise() is huge for a reason or whether it can be split into individual tests. I'm guessing that it's huge for a reason, because all the asserts seem to be of the nature of
foo = bar.foo assertEqual( expected_ foo, foo)
self.
Which is fine, but given the length of the method they should have some explanation with them:
# The bar's foo will have been updated. assertEqual( expected_ foo, foo)
foo = bar.foo
self.
As I said, I don't have the context for knowing if the test conversion is accurate, since the old test seems to rely a lot on the output from the script. I'd appreciate it if you could find someone else (Jools maybe) who can confirm that (I'm aware that this is overkill but I'm also aware that this is a Soyuz branch).
I'm marking the branch as needs fixing pending the changes above.