Merge lp:~adeuring/launchpad/bug-528569-api-bug-search-for-linked-branches into lp:launchpad

Proposed by Abel Deuring
Status: Merged
Merged at revision: not available
Proposed branch: lp:~adeuring/launchpad/bug-528569-api-bug-search-for-linked-branches
Merge into: lp:launchpad
Diff against target: 62 lines (+33/-2)
2 files modified
lib/lp/bugs/interfaces/bugtarget.py (+7/-2)
lib/lp/bugs/stories/webservice/xx-bug.txt (+26/-0)
To merge this branch: bzr merge lp:~adeuring/launchpad/bug-528569-api-bug-search-for-linked-branches
Reviewer Review Type Date Requested Status
Gavin Panella (community) code Approve
Review via email: mp+21058@code.launchpad.net

Description of the change

This branch fixes bug 528569: searching bug tasks by linked_branches not exported in the API

Just the boilerplate markup for webservice export of yet another parameter of IHasBugs.searchtasks() and a short test:

./bin/test -t webservice/xx-bug.txt

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/bugs/interfaces/bugtarget.py
  lib/lp/bugs/stories/webservice/xx-bug.txt

== Pylint notices ==

lib/lp/bugs/interfaces/bugtarget.py
    62: [C0301] Line too long (79/78)
    29: [F0401] Unable to import 'lazr.enum' (No module named enum)
    30: [F0401] Unable to import 'lazr.restful.fields' (No module named restful)
    31: [F0401] Unable to import 'lazr.restful.interface' (No module named restful)
    32: [F0401] Unable to import 'lazr.restful.declarations' (No module named restful)
    68: [C0322, IHasBugs.searchTasks] Operator not preceded by a space
    value_type=Text(),
    ^
    required=False),
    search_text=copy_field(IBugTaskSearch['searchtext']),
    status=copy_field(IBugTaskSearch['status']),
    importance=copy_field(IBugTaskSearch['importance']),
    assignee=Reference(schema=Interface),
    bug_reporter=Reference(schema=Interface),
    bug_supervisor=Reference(schema=Interface),
    bug_commenter=Reference(schema=Interface),
    bug_subscriber=Reference(schema=Interface),
    owner=Reference(schema=Interface),
    affected_user=Reference(schema=Interface),
    has_patch=copy_field(IBugTaskSearch['has_patch']),
    has_cve=copy_field(IBugTaskSearch['has_cve']),
    tags=copy_field(IBugTaskSearch['tag']),
    tags_combinator=copy_field(IBugTaskSearch['tags_combinator']),
    omit_duplicates=copy_field(IBugTaskSearch['omit_dupes']),
    omit_targeted=copy_field(IBugTaskSearch['omit_targeted']),
    status_upstream=copy_field(IBugTaskSearch['status_upstream']),
    milestone_assignment=copy_field(
    IBugTaskSearch['milestone_assignment']),
    milestone=copy_field(IBugTaskSearch['milestone']),
    component=copy_field(IBugTaskSearch['component']),
    nominated_for=Reference(schema=Interface),
    has_no_package=copy_field(IBugTaskSearch['has_no_package']),
    hardware_bus=Choice(
    title=u'The bus of a hardware device related to a bug',

    vocabulary=DBEnumeratedType, required=False),
    hardware_vendor_id=TextLine(
    title=(
    u"The vendor ID of a hardware device related to a bug."),
    description=(
    u"Allowed values of the vendor ID depend on the bus of the "
    "device.nn"
    "Vendor IDs of PCI, PCCard and USB devices are hexadecimal "
    "string representations of 16 bit integers in the format "
    "'0x01ab': The prefix '0x', followed by exactly 4 digits; "
    "where a digit is one of the characters 0..9, a..f. The "
    "characters A..F are not allowed.nn"
    "SCSI vendor IDs are strings with exactly 8 characters. "
    "Shorter names are right-padded with space (0x20) characters."
    "nn"
    "IDs for other buses may be arbitrary strings."),
    required=False),
    hardware_product_id=TextLine(
    title=(
    u"The product ID of a hardware device related to a bug."),
    description=(
    u"Allowed values of the product ID depend on the bus of the "
    "device.nn"
    "Product IDs of PCI, PCCard and USB devices are hexadecimal "
    "string representations of 16 bit integers in the format "
    "'0x01ab': The prefix '0x', followed by exactly 4 digits; "
    "where a digit is one of the characters 0..9, a..f. The "
    "characters A..F are not allowed.nn"
    "SCSI product IDs are strings with exactly 16 characters. "
    "Shorter names are right-padded with space (0x20) characters."
    "nn"
    "IDs for other buses may be arbitrary strings."),
    required=False),
    hardware_driver_name=TextLine(
    title=(
    u"The driver controlling a hardware device related to a "
    "bug."),
    required=False),
    hardware_driver_package_name=TextLine(
    title=(
    u"The package of the driver which controls a hardware "
    "device related to a bug."),
    required=False),
    hardware_owner_is_bug_reporter=Bool(
    title=(
    u"Search for bugs reported by people who own the given "
    "device or who use the given hardware driver."),
    required=False),
    hardware_owner_is_affected_by_bug=Bool(
    title=(
    u"Search for bugs where people affected by a bug own the "
    "given device or use the given hardware driver."),
    required=False),
    hardware_owner_is_subscribed_to_bug=Bool(
    title=(
    u"Search for bugs where a bug subscriber owns the "
    "given device or uses the given hardware driver."),
    required=False),
    hardware_is_linked_to_bug=Bool(
    title=(
    u"Search for bugs which are linked to hardware reports "
    "wich contain the given device or whcih contain a device"
    "contolled by the given driver."),
    required=False),
    linked_branches=Choice(
    title=(
    u"Search for bugs that are linked to branches or for bugs"
    "that are not linked to branches."),
    vocabulary=BugBranchSearch, required=False))
    @operation_returns_collection_of(IBugTask)
    @export_read_operation()
    def searchTasks(search_params, user=None,
    order_by=None, search_text=None,
    status=None, importance=None,
    assignee=None, bug_reporter=None, bug_supervisor=None,
    bug_commenter=None, bug_subscriber=None, owner=None,
    affected_user=None, has_patch=None, has_cve=None,
    distribution=None, tags=None,
    tags_combinator=BugTagsSearchCombinator.ALL,
    omit_duplicates=True, omit_targeted=None,
    status_upstream=None, milestone_assignment=None,
    milestone=None, component=None, nominated_for=None,
    sourcepackagename=None, has_no_package=None,
    hardware_bus=None, hardware_vendor_id=None,
    hardware_product_id=None, hardware_driver_name=None,
    hardware_driver_package_name=None,
    hardware_owner_is_bug_reporter=None,
    hardware_owner_is_affected_by_bug=False,
    hardware_owner_is_subscribed_to_bug=False,
    hardware_is_linked_to_bug=False, linked_branches=None):

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Having to use the long name from the enum when passing this parameter is truly awful, but I don't think that's your problem right now. Looks good.

review: Approve (code)
Revision history for this message
Abel Deuring (adeuring) wrote :

Hi Gavin,

thanks for the review!

On 10.03.2010 18:21, Gavin Panella wrote:
> Review: Approve code
> Having to use the long name from the enum when passing this parameter is
> truly awful, but I don't think that's your problem right now. Looks good.

Right, the parameter values do not look very pretty. The problem is that
they were intended to become labels for radio buttons in the web ui, and
in this context they are more reasonable. I must admit that I never
liked the concept to use the title of enum items in calls of the
webservice API...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/interfaces/bugtarget.py'
2--- lib/lp/bugs/interfaces/bugtarget.py 2010-03-08 09:38:21 +0000
3+++ lib/lp/bugs/interfaces/bugtarget.py 2010-03-10 15:01:24 +0000
4@@ -25,7 +25,7 @@
5 from canonical.launchpad import _
6 from canonical.launchpad.fields import Tag
7 from lp.bugs.interfaces.bugtask import (
8- BugTagsSearchCombinator, IBugTask, IBugTaskSearch)
9+ BugBranchSearch, BugTagsSearchCombinator, IBugTask, IBugTaskSearch)
10 from lazr.enum import DBEnumeratedType
11 from lazr.restful.fields import Reference
12 from lazr.restful.interface import copy_field
13@@ -157,7 +157,12 @@
14 u"Search for bugs which are linked to hardware reports "
15 "wich contain the given device or whcih contain a device"
16 "contolled by the given driver."),
17- required=False))
18+ required=False),
19+ linked_branches=Choice(
20+ title=(
21+ u"Search for bugs that are linked to branches or for bugs"
22+ "that are not linked to branches."),
23+ vocabulary=BugBranchSearch, required=False))
24 @operation_returns_collection_of(IBugTask)
25 @export_read_operation()
26 def searchTasks(search_params, user=None,
27
28=== modified file 'lib/lp/bugs/stories/webservice/xx-bug.txt'
29--- lib/lp/bugs/stories/webservice/xx-bug.txt 2010-03-08 16:07:40 +0000
30+++ lib/lp/bugs/stories/webservice/xx-bug.txt 2010-03-10 15:01:24 +0000
31@@ -1717,6 +1717,32 @@
32 HTTP/1.1 400 Bad Request...
33
34
35+Searching for bugs that are linked to branches
36+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37+
38+We can search for bugs that are linked to branches...
39+
40+ >>> bugtasks = webservice.named_get(
41+ ... '/firefox', 'searchTasks',
42+ ... linked_branches='Show only Bugs with linked Branches')
43+ >>> for bugtask in bugtasks.jsonBody()['entries']:
44+ ... print bugtask['self_link']
45+ http://api.launchpad.dev/beta/firefox/+bug/5
46+ http://api.launchpad.dev/beta/firefox/+bug/4
47+
48+...and we can search for bugs that are not linked to branches.
49+
50+ >>> bugtasks = webservice.named_get(
51+ ... '/firefox', 'searchTasks',
52+ ... linked_branches='Show only Bugs without linked Branches')
53+ >>> for bugtask in bugtasks.jsonBody()['entries']:
54+ ... print bugtask['self_link']
55+ http://api.launchpad.dev/beta/firefox/+bug/1
56+ http://api.launchpad.dev/beta/firefox/+bug/16
57+ http://api.launchpad.dev/beta/firefox/+bug/20
58+ http://api.launchpad.dev/beta/firefox/+bug/22
59+
60+
61 Affected users
62 --------------
63