Merge lp://staging/~jpds/launchpad/fix_361650_model_changes into lp://staging/launchpad

Proposed by Jonathan Davies
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 10619
Proposed branch: lp://staging/~jpds/launchpad/fix_361650_model_changes
Merge into: lp://staging/launchpad
Diff against target: 857 lines (+470/-93)
11 files modified
lib/lp/registry/configure.zcml (+47/-5)
lib/lp/registry/doc/distribution-mirror.txt (+119/-1)
lib/lp/registry/interfaces/distribution.py (+9/-1)
lib/lp/registry/interfaces/distributionmirror.py (+96/-47)
lib/lp/registry/model/distribution.py (+11/-0)
lib/lp/registry/model/distributionmirror.py (+63/-1)
lib/lp/registry/stories/distributionmirror/xx-distribution-mirrors.txt (+11/-11)
lib/lp/registry/stories/webservice/xx-distribution-mirror.txt (+20/-11)
lib/lp/registry/stories/webservice/xx-distribution.txt (+74/-0)
lib/lp/registry/tests/test_distributionmirror.py (+4/-14)
lib/lp/testing/factory.py (+16/-2)
To merge this branch: bzr merge lp://staging/~jpds/launchpad/fix_361650_model_changes
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+20785@code.staging.launchpad.net

Commit message

Added models and tests for DistributionMirror.country_dns_mirror.

Description of the change

= Summary =

This branch builds on the schema changes introduced for bug #361650. Adding stuff to our models.

It also adds the API parts and mirror checks when marking mirrors as country mirrors with complete test suite.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :
Download full text (23.1 KiB)

Your merge proposal should show the output of make lint to verify your
changes did not have any cruft. It will also inform you of style mistakes
that must be fixed before making a merge proposal.

I have some ideas to improve the code, and I think the interface and model
are missing essential documentation and unit tests. I suspect that the
story tests (which are integration tests) are test what should be testing
as documentation and unit tests.

> === modified file 'lib/lp/registry/interfaces/distribution.py'
> --- lib/lp/registry/interfaces/distribution.py 2010-02-27 10:19:18 +0000
> +++ lib/lp/registry/interfaces/distribution.py 2010-03-06 00:09:35 +0000
> @@ -318,6 +318,16 @@
> if it's not found.
> """
>
> + @operation_parameters(
> + country=copy_field(IDistributionMirror['country'], required=True),
> + mirror_type=copy_field(IDistributionMirror['content'], required=True))
> + @operation_returns_entry(IDistributionMirror)
> + @export_read_operation()
> + def getCountryMirror(country, mirror_type):
> + """Return the country DNS mirror for a given country and content
> + type.
> + """
> +

This docstring does not follow PEP 257. The first sentence must be one line.
Subsequent sentences may follow after a blank line:
    http://www.python.org/dev/peps/pep-0257/

Think this fixes the issue:

        """Return the country DNS mirror for a country and content type."""

> === modified file 'lib/lp/registry/interfaces/distributionmirror.py'
> --- lib/lp/registry/interfaces/distributionmirror.py 2010-02-22 15:50:06 +0000
> +++ lib/lp/registry/interfaces/distributionmirror.py 2010-03-06 00:09:35 +0000
> @@ -6,21 +6,23 @@
> __metaclass__ = type
>
> __all__ = [
> +'CannotTransitionToCountryMirror',
> +'CountryMirrorAlreadySet',
> 'IDistributionMirror',
> -'IDistributionMirrorAdminRestricted',
> -'IDistributionMirrorEditRestricted',
> -'IDistributionMirrorPublic',
> 'IMirrorDistroArchSeries',
> 'IMirrorDistroSeriesSource',
> 'IMirrorProbeRecord',
> 'IDistributionMirrorSet',
> 'IMirrorCDImageDistroSeries',
> 'PROBE_INTERVAL',
> -'UnableToFetchCDImageFileList',
> 'MirrorContent',
> 'MirrorFreshness',
> +'MirrorHasNoHTTPUrl',
> +'MirrorNotOfficial',
> +'MirrorNotProbed',
> 'MirrorSpeed',
> -'MirrorStatus']
> +'MirrorStatus',
> +'UnableToFetchCDImageFileList']

Per PEP 8, this list of single entries must each be indented and required a
trailing comma; the closing bracket on on a separate line to minimise diffs,
which I can see that this diff is already a victim:

    'MirrorStatus',
    'UnableToFetchCDImageFileList',
    ]

> @@ -47,6 +52,44 @@
> PROBE_INTERVAL = 23
>
> +class CannotTransitionToCountryMirror(Exception):
> + """Root exception for transitions to country mirrors.
> + """

The closing quotes belong on the previous line PEP 257.

> + webservice_error(400) # HTTP Error: 'Bad Request'.

Launchpad style does not use trailing comments because they interfere with
refactoring. I do not think comments about HTTP codes are informative;
we are expect to know them.

> @@ -386,6 +406,33 @@
> date_created = exported(Datetime(
> title=_('Date Crea...

review: Needs Fixing (code)
Revision history for this message
Curtis Hovey (sinzui) wrote :
Download full text (5.9 KiB)

Hi Jonathan.

I have some trivial suggestions to improve this branch. I think the implementation
is good and ready to land.

I can land the branch at the end of this week after these changes are made.

make lint reported these problems that need fixing:

lib/lp/registry/interfaces/distributionmirror.py
    339: [C0301] Line too long (83/78)
    436: [W0311] Bad indentation. Found 7 spaces, expected 8

> === modified file 'lib/lp/registry/doc/distribution-mirror.txt'
> --- lib/lp/registry/doc/distribution-mirror.txt 2009-12-09 10:03:20 +0000
> +++ lib/lp/registry/doc/distribution-mirror.txt 2010-03-29 15:54:12 +0000

@@ -814,3 +814,107 @@

> +Country DNS mirrors
> +-------------------
> +
> +Country DNS mirrors are mirrors which have been assigned $CC.archive.ubuntu.com
> +or $CC.releases.ubuntu.com. These assignments are tracked in Launchpad.

Wrap the narrative at 78 characters.

> + >>> login('<email address hidden>')
> + >>> ubuntu_distro = getUtility(IDistributionSet).getByName('ubuntu')
> + >>> de_archive_mirror = factory.makeMirror(ubuntu_distro,
> + ... "Technische Universitaet Dresden", country=82,
> + ... http_url="http://ubuntu.mirror.tudos.de/ubuntu/",
> + ... official_candidate=True)
> + >>> davis_station_archive = factory.makeMirror(ubuntu_distro,
> + ... "Davis Station", country=9,
> + ... http_url="http://mirror.davis.antarctica.org/ubuntu",
> + ... official_candidate=True)
> + >>> de_archive_mirror.status = MirrorStatus.OFFICIAL
> + >>> de_archive_prober_log = factory.makeMirrorProbeRecord(de_archive_mirror)
> + >>> logout()

Wrap the code at 78 characters.

...

> +Mirrors which are not official or do not have an HTTP URL may not be set as
> +country mirrors:
> +
> + >>> login('<email address hidden>')
> + >>> osuosl_mirror = factory.makeMirror(ubuntu_distro, "OSU Open Source Lab",
> + ... country=226,
> + ... ftp_url="ftp://ubuntu.osuosl.org/pub/ubuntu/",
> + ... official_candidate=True)
> + >>> osuosl_mirror.status = MirrorStatus.OFFICIAL
> + >>> print osuosl_mirror.http_base_url
> + None

Wrap the code at 78 characters.

> === modified file 'lib/lp/registry/interfaces/distribution.py'
> --- lib/lp/registry/interfaces/distribution.py 2010-03-24 21:59:58 +0000
> +++ lib/lp/registry/interfaces/distribution.py 2010-03-29 15:54:12 +0000
>
> @@ -321,6 +321,14 @@
> if it's not found.
> """
>
> + @operation_parameters(
> + country=copy_field(IDistributionMirror['country'], required=True),
> + mirror_type=copy_field(IDistributionMirror['content'], required=True))
> + @operation_returns_entry(IDistributionMirror)
> + @export_read_operation()
> + def getCountryMirror(country, mirror_type):
> + """Return the country DNS mirror for acountry and content type."""

grammar: s/acountry/a country/

> === modified file 'lib/lp/registry/interfaces/distributionmirror.py'
> --- lib/lp/registry/interfaces/distributionmirror.py 2010-02-22 15:50:06 +0000
> +++ lib/lp/registry/interfaces/distributionmirror.py 2010-03-29 15:54:12 +0000
> @@ -6,21 +6,24 @@
> __metaclass__ = type

 __all__ = [
...

> + ...

Read more...

review: Needs Fixing (code)
Revision history for this message
Curtis Hovey (sinzui) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.