On Monday 05 July 2010 11:07:27 Henning Eggers wrote:
> Hi Jelmer,
> thank you for this quick fix. I have a few comments about the tests and
> will wait for your reply before I approve the branch.
>
> Cheers,
> Henning
Thanks Henning.
I'm taking this over since Jelmer's away for 2 weeks.
> > + ubuntu = getUtility(IDistributionSet)['ubuntu']
> > + self.ubuntu_archive = ubuntu.main_archive
>
> We have a celebrity that you should use for this.
>
> getUtility(ILaunchpadCelebrities).ubuntu
We hardly ever use it in Soyuz code, I don't see point of changing it here,
celebs should be optional.
> > { 'arm' : False, 'cell-proc' : True, 'omap' : False},
>
> Leading space. ^ Copied&pasted further down ... ;)
I'll fix those.
>
> > results)
> >
> > + def test_restricted_association_archive_only(self):
> Looks like this naming is used throughout this file but the correct name
> would probably be "test_getRestrictedFamilies_archive_only" or similar.
>
> https://dev.launchpad.net/TestsStyleGuide#Python Test Cases
Yeah those are wrong, I'll fix the names.
> > + """Test that only the associated archs for the archive itself
> > are + returned."""
>
> This doc string violates our docstring conventions but you don't need a doc
> string for test methods anyway, just a comment.
I'll fix that too!
> # Test that only the associated archs for the archive itself are
> # returned.
>
> I see more instances of that, maybe you correct fix them as a drive-by fix?
> Thank you very much!
I need to get an R-C for this so I'll leave that for another time if you don't
mind :)
>
> > + getUtility(IArchiveArchSet).new(self.ppa, self.cell_proc)
> > + getUtility(IArchiveArchSet).new(self.ubuntu_archive, self.omap)
>
> Hm, maybe you could add a factory method to the LaunchpadObjectFactory for
> ArchiveArch? Or are there reasons against that?
We could do. But this is an R-C so we'll do it later!
>
> > + result_set = list(
> > + getUtility(IArchiveArchSet).getRestrictedfamilies(self.ppa))
>
> Else, the repeated calls to getUtility(IArchiveArchSet) clutter the code.
> Maybe you should use a local or instance variable to store that?
I can do that.
> Also, I think getRestrictedfamilies should be getRestrictedFamilies to be
> proper camelCase. I know this is not your doing but could you please fix
> that if it does not have too many call sites?
Yeah I can fix that.
> > + results = dict(
> > + (row[0].name, row[1] is not None) for row in result_set)
> > + self.assertEquals(
> > + { 'arm' : False, 'cell-proc' : True, 'omap' : False},
>
> Leading space. ^
>
> > + self.assertEquals(1, len(result_set))
> > + self.assertEquals(self.ppa, result_set[0].archive)
> > + self.assertEquals(self.cell_proc, result_set[0].processorfamily)
>
> I quite liked the approach from the first test where you converted the
> complex result set to a dict. Maybe you can do something similar here to
> have only one assert in the end? In case of a test failure the failure
> message will be much clearer.
The assertions are also the wrong way around, we use:
assertEqual(actual value, expected value)
I prefer the non-dictionary approach myself. The (missing) third arg to
assertEqual should be a string that explains the failure.
A non-matching dictionary would look messy in comparison, no?
> My suggestion:
>
> result = [(row.archive, row.processorfamily) for row in result_set]
> self.assertEqual([(self.ppa, self.cell_proc)], result)
On Monday 05 July 2010 11:07:27 Henning Eggers wrote:
> Hi Jelmer,
> thank you for this quick fix. I have a few comments about the tests and
> will wait for your reply before I approve the branch.
>
> Cheers,
> Henning
Thanks Henning.
I'm taking this over since Jelmer's away for 2 weeks.
> > + ubuntu = getUtility( IDistributionSe t)['ubuntu' ] ILaunchpadCeleb rities) .ubuntu
> > + self.ubuntu_archive = ubuntu.main_archive
>
> We have a celebrity that you should use for this.
>
> getUtility(
We hardly ever use it in Soyuz code, I don't see point of changing it here,
celebs should be optional.
> > { 'arm' : False, 'cell-proc' : True, 'omap' : False},
>
> Leading space. ^ Copied&pasted further down ... ;)
I'll fix those.
> _association_ archive_ only(self) : ctedFamilies_ archive_ only" or similar. /dev.launchpad. net/TestsStyleG uide#Python Test Cases
> > results)
> >
> > + def test_restricted
> Looks like this naming is used throughout this file but the correct name
> would probably be "test_getRestri
>
> https:/
Yeah those are wrong, I'll fix the names.
> > + """Test that only the associated archs for the archive itself
> > are + returned."""
>
> This doc string violates our docstring conventions but you don't need a doc
> string for test methods anyway, just a comment.
I'll fix that too!
> # Test that only the associated archs for the archive itself are
> # returned.
>
> I see more instances of that, maybe you correct fix them as a drive-by fix?
> Thank you very much!
I need to get an R-C for this so I'll leave that for another time if you don't
mind :)
> IArchiveArchSet ).new(self. ppa, self.cell_proc) IArchiveArchSet ).new(self. ubuntu_ archive, self.omap) Factory for
> > + getUtility(
> > + getUtility(
>
> Hm, maybe you could add a factory method to the LaunchpadObject
> ArchiveArch? Or are there reasons against that?
We could do. But this is an R-C so we'll do it later!
> IArchiveArchSet ).getRestricted families( self.ppa) ) IArchiveArchSet ) clutter the code.
> > + result_set = list(
> > + getUtility(
>
> Else, the repeated calls to getUtility(
> Maybe you should use a local or instance variable to store that?
I can do that.
> Also, I think getRestrictedfa milies should be getRestrictedFa milies to be
> proper camelCase. I know this is not your doing but could you please fix
> that if it does not have too many call sites?
Yeah I can fix that.
> > + results = dict(
> > + (row[0].name, row[1] is not None) for row in result_set)
> > + self.assertEquals(
> > + { 'arm' : False, 'cell-proc' : True, 'omap' : False},
>
> Leading space. ^
Yep.
> by_archive( self): getByArchive. """ IArchiveArchSet ).new(self. ppa, self.cell_proc) IArchiveArchSet ).new(self. ubuntu_ archive, self.omap) IArchiveArchSet ).getByArchive( self.ppa) )
> > + results)
> > +
> > + def test_get_
> > + """Test ArchiveArchSet.
> > + getUtility(
> > + getUtility(
> > + result_set = list(
> > + getUtility(
>
> Same comment about storing archive_arch_set
Yep.
> ls(1, len(result_set)) ls(self. ppa, result_ set[0]. archive) ls(self. cell_proc, result_ set[0]. processorfamily )
> > + self.assertEqua
> > + self.assertEqua
> > + self.assertEqua
>
> I quite liked the approach from the first test where you converted the
> complex result set to a dict. Maybe you can do something similar here to
> have only one assert in the end? In case of a test failure the failure
> message will be much clearer.
The assertions are also the wrong way around, we use:
assertEqual(actual value, expected value)
I prefer the non-dictionary approach myself. The (missing) third arg to
assertEqual should be a string that explains the failure.
A non-matching dictionary would look messy in comparison, no?
> My suggestion: mily) for row in result_set] l([(self. ppa, self.cell_proc)], result)
>
> result = [(row.archive, row.processorfa
> self.assertEqua
I find this quite hard to read as a test :(
Cheers
J