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
=== modified file 'lib/lp/bugs/interfaces/bugtarget.py'
--- lib/lp/bugs/interfaces/bugtarget.py 2010-03-08 09:38:21 +0000
+++ lib/lp/bugs/interfaces/bugtarget.py 2010-03-10 15:01:24 +0000
@@ -25,7 +25,7 @@
25from canonical.launchpad import _25from canonical.launchpad import _
26from canonical.launchpad.fields import Tag26from canonical.launchpad.fields import Tag
27from lp.bugs.interfaces.bugtask import (27from lp.bugs.interfaces.bugtask import (
28 BugTagsSearchCombinator, IBugTask, IBugTaskSearch)28 BugBranchSearch, BugTagsSearchCombinator, IBugTask, IBugTaskSearch)
29from lazr.enum import DBEnumeratedType29from lazr.enum import DBEnumeratedType
30from lazr.restful.fields import Reference30from lazr.restful.fields import Reference
31from lazr.restful.interface import copy_field31from lazr.restful.interface import copy_field
@@ -157,7 +157,12 @@
157 u"Search for bugs which are linked to hardware reports "157 u"Search for bugs which are linked to hardware reports "
158 "wich contain the given device or whcih contain a device"158 "wich contain the given device or whcih contain a device"
159 "contolled by the given driver."),159 "contolled by the given driver."),
160 required=False))160 required=False),
161 linked_branches=Choice(
162 title=(
163 u"Search for bugs that are linked to branches or for bugs"
164 "that are not linked to branches."),
165 vocabulary=BugBranchSearch, required=False))
161 @operation_returns_collection_of(IBugTask)166 @operation_returns_collection_of(IBugTask)
162 @export_read_operation()167 @export_read_operation()
163 def searchTasks(search_params, user=None,168 def searchTasks(search_params, user=None,
164169
=== modified file 'lib/lp/bugs/stories/webservice/xx-bug.txt'
--- lib/lp/bugs/stories/webservice/xx-bug.txt 2010-03-08 16:07:40 +0000
+++ lib/lp/bugs/stories/webservice/xx-bug.txt 2010-03-10 15:01:24 +0000
@@ -1717,6 +1717,32 @@
1717 HTTP/1.1 400 Bad Request...1717 HTTP/1.1 400 Bad Request...
17181718
17191719
1720Searching for bugs that are linked to branches
1721~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1722
1723We can search for bugs that are linked to branches...
1724
1725 >>> bugtasks = webservice.named_get(
1726 ... '/firefox', 'searchTasks',
1727 ... linked_branches='Show only Bugs with linked Branches')
1728 >>> for bugtask in bugtasks.jsonBody()['entries']:
1729 ... print bugtask['self_link']
1730 http://api.launchpad.dev/beta/firefox/+bug/5
1731 http://api.launchpad.dev/beta/firefox/+bug/4
1732
1733...and we can search for bugs that are not linked to branches.
1734
1735 >>> bugtasks = webservice.named_get(
1736 ... '/firefox', 'searchTasks',
1737 ... linked_branches='Show only Bugs without linked Branches')
1738 >>> for bugtask in bugtasks.jsonBody()['entries']:
1739 ... print bugtask['self_link']
1740 http://api.launchpad.dev/beta/firefox/+bug/1
1741 http://api.launchpad.dev/beta/firefox/+bug/16
1742 http://api.launchpad.dev/beta/firefox/+bug/20
1743 http://api.launchpad.dev/beta/firefox/+bug/22
1744
1745
1720Affected users1746Affected users
1721--------------1747--------------
17221748