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.assertRaisesWithContent() which will ensure that the cause of the raised exception is obvious.
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,
From here...
+ foobuntu = self._create_distroseries(self.hoary)
+ self._set_pending_to_failed(self.hoary)
+ transaction.commit()
+ ids = InitialiseDistroSeries(foobuntu)
+ ids.check()
+ ids.initialise()
to here could be extracted into self._initialise_distroseries() ?
...to here into self.assertDistroSeriesEqual() (hrm.. with a more accurate method name), so you have a nice small test using your own assertion which does all the required checks... just a bit more readable.
looks like it should be a separate test (which could use the same self._initialise_distroseries()), with an appropriate method comment based on the doctest (ie. *why* doesn't this build exist... the doctest takes 3 paragraphs to explain :/)
looks like a separate test also (again which could use the same self._initialise_distroseries()).
The following isn't commented in the doctest... does it belong with the above? If so, what are we ensuring here that is different from the similar test for foobuntu['i386']... if it's nothing new, I'd remove it:
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 esWithContent( ) which will ensure that the cause of the raised exception is obvious.
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/ soyuz/scripts/ tests/test_ initialise_ distroseries. py' soyuz/scripts/ tests/test_ initialise_ distroseries. py 1970-01-01 00:00:00 +0000 soyuz/scripts/ tests/test_ initialise_ distroseries. py 2010-08-10 14:55:27 +0000 (self):
--- lib/lp/
+++ lib/lp/
@@ -0,0 +1,144 @@
<snip>
+
+ def test_initialise
From here... distroseries( self.hoary) pending_ to_failed( self.hoary) commit( ) oSeries( foobuntu) e_distroseries( ) ?
+ foobuntu = self._create_
+ self._set_
+ transaction.
+ ids = InitialiseDistr
+ ids.check()
+ ids.initialise()
to here could be extracted into self._initialis
and then from here: getPublishedRel eases(' pmount' ) pmount_ pubs = foobuntu. getPublishedRel eases(' pmount' ) l(len(hoary_ pmount_ pubs), len(foobuntu_ pmount_ pubs)) pmount_ pubs = self.hoary[ 'i386'] .getReleasedPac kages( i386_pmount_ pubs = foobuntu[ 'i386'] .getReleasedPac kages( i386_pmount_ pubs), len(foobuntu_ i386_pmount_ pubs)) 'i386'] .getReleasedPac kages( )[0].binarypack agerelease) l(pmount_ binrel. title, u'pmount-0.1-1') l(pmount_ binrel. build.id, 7) binrel. build.title, binrel. build.source_ package_ release l(pmount_ srcrel. title, u'pmount - 0.1-1') srcrel. getBuildByArch( main_archive) srcrel. getBuildByArch( main_archive) l(foobuntu_ pmount. id, hoary_pmount.id) getSourcePackag e( ).currentreleas e source. title, getSourcePackag e('pmount' ).currentreleas e source. title,
+ 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 roSeriesEqual( ) (hrm.. with a more accurate method name), so you have a nice small test using your own assertion which does all the required checks... just a bit more readable.
but this bit:
+ self.assertEqual( source. sourcepackagere lease.getBuildB yArch( main_archive) , None)
+ pmount_
+ foobuntu['i386'], foobuntu.
looks like it should be a separate test (which could use the same self._initialis e_distroseries( )), with an appropriate method comment based on the doctest (ie. *why* doesn't this build exist... the doctest takes 3 paragraphs to explain :/)
And then this bit:
+ created_build = pmount_ source. sourcepackagere lease.createBui ld( ngPocket. RELEASE, main_archive) source. sourcepackagere lease.getBuildB yArch( main_archive) l(retrieved_ build.id, created_build.id)
+ foobuntu['i386'], PackagePublishi
+ foobuntu.
+ retrieved_build = pmount_
+ foobuntu['i386'], foobuntu.
+ self.assertEqua
looks like a separate test also (again which could use the same self._initialis e_distroseries( )).
The following isn't commented in the doctest... does it belong with the above? If so, what are we ensuring here that is different from the similar test for foobuntu['i386']... if it's nothing new, I'd remove it:
+ self.assertEqual( source. sourcepackagere lease.getBuildB yArch( main_archive) , None)
+ pmount_
+ foobuntu['hppa'], foobuntu.
And this last bit looks like it could belong with the self.assertDist roSeriesEqual( ) (or whatever you call it), but needs the comment from the doctest
+ self.assertTrue( isSourcePackage FormatPermitted ( rmat.FORMAT_ 1_0))
+ foobuntu.
+ SourcePackageFo
+ distroseries( self.hoary) pending_ to_failed( self.hoary) commit( ) from-parent. py') subprocess. PIPE, stderr= subprocess. PIPE) communicate( ) l(process. returncode, 0) getPublishedRel eases(+ foobuntu_ pmount_ pubs = foobuntu. getPublishedRel eases(' pmount' ) l(len(hoary_ pmount_ pubs), len(foobuntu_ pmount_ pubs))
+ def test_script(self):
+ foobuntu = self._create_
+ self._set_
+ transaction.
+ ifp = os.path.join(
+ config.root, 'scripts', 'ftpmaster-tools',
+ 'initialise-
+ process = subprocess.Popen(
+ [sys.executable, ifp, "-vv", "-d", "ubuntutest", "foobuntu"],
+ stdout=
+ stdout, stderr = process.
+ self.assertEqua
+ self.assertTrue(
+ "DEBUG Committing transaction." in stderr.split('\n'))
+ hoary_pmount_pubs = self.hoary.
+ self.assertEqua
'pmount')
I assume you could again use the self.assertDist roSeriesEqual( ) (with a better name).
Thanks!