~ursinha/launchpad/add-all-fl-tests

« back to all changes in this revision

Viewing changes to lib/canonical/launchpad/pagetests/webservice/xx-hwdb.txt

  • Committer: Launchpad Patch Queue Manager
  • Date: 2009-08-20 12:36:07 UTC
  • mfrom: (9094.2.2 hwdb-device-class-api)
  • Revision ID: launchpad@pqm.canonical.com-20090820123607-w7k7ahwkclxlonh8
[r=cprov][ui=none] allow arbitrary int values for
        HWDeviceClass.main_class and HWDeviceClass.sub_class;
        expose HWDeviceClass to the webservice

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    ...     pprint_entry(entry)
38
38
    bus: u'System'
39
39
    bus_product_id: u'MS-7369'
 
40
    classes_collection_link: u'.../+hwdb/+device/1/classes'
40
41
    drivers_collection_link: u'.../+hwdb/+device/1/drivers'
41
42
    id: 1
42
43
    name: u'MS-7369'
78
79
    ...     pprint_entry(entry)
79
80
    bus: u'System'
80
81
    bus_product_id: u'MS-7369'
 
82
    classes_collection_link: u'.../+hwdb/+device/1/classes'
81
83
    drivers_collection_link: u'.../+hwdb/+device/1/drivers'
82
84
    id: 1
83
85
    name: u'MS-7369'
115
117
    >>> pprint_entry(device)
116
118
    bus: u'PCI'
117
119
    bus_product_id: u'0x0455'
 
120
    classes_collection_link: u'.../+hwdb/+device/2/classes'
118
121
    drivers_collection_link: u'.../+hwdb/+device/2/drivers'
119
122
    id: 2
120
123
    name: u'MCP65 USB Controller'
164
167
    resource_type_link: u'http://api.launchpad.dev/beta/#h_w_driver'
165
168
    self_link: u'http://api.launchpad.dev/beta/+hwdb/+driver/2'
166
169
 
 
170
We can add and retrieve class data, i.e., the type of a device (printer,
 
171
scanner, sound device) for a device. Device 2 is a PCI USB controller,
 
172
having the main PCI class 12 and sub-class 3. Let's add a new device
 
173
class record for this device by calling device.getOrCreateDevice(). This
 
174
call returns a reference to a HWDeviceClass record.
 
175
 
 
176
    >>> class_info = webservice.named_post(
 
177
    ...     '/+hwdb/+device/2', 'getOrCreateDeviceClass', {}, main_class=12,
 
178
    ...     sub_class=3).jsonBody()
 
179
    >>> pprint_entry(class_info)
 
180
    main_class: 12
 
181
    resource_type_link: u'http://api.launchpad.dev/beta/#h_w_device_class'
 
182
    self_link: u'http://api.launchpad.dev/beta/+hwdb/+deviceclass/1'
 
183
    sub_class: 3
 
184
 
 
185
A second call of this method returns the same record.
 
186
 
 
187
    >>> class_info = webservice.named_post(
 
188
    ...     '/+hwdb/+device/2', 'getOrCreateDeviceClass', {}, main_class=12,
 
189
    ...     sub_class=3).jsonBody()
 
190
    >>> print class_info['self_link']
 
191
    http://api.launchpad.dev/beta/+hwdb/+deviceclass/1
 
192
 
 
193
The property device.classes returns the collection of all classes
 
194
assigned to the device.
 
195
 
 
196
    >>> class_info = webservice.get('/+hwdb/+device/2/classes').jsonBody()
 
197
    >>> for entry in class_info['entries']:
 
198
    ...     pprint_entry(entry)
 
199
    main_class: 12
 
200
    resource_type_link: u'http://api.launchpad.dev/beta/#h_w_device_class'
 
201
    self_link: u'http://api.launchpad.dev/beta/+hwdb/+deviceclass/1'
 
202
    sub_class: 3
 
203
 
 
204
We can delete existing class data by calling deviceclass.delete().
 
205
 
 
206
    >>> print webservice.delete(class_info['entries'][0]['self_link'])
 
207
    HTTP/1.1 200 Ok
 
208
    ...
 
209
 
 
210
    >>> class_info = webservice.get('/+hwdb/+device/2/classes').jsonBody()
 
211
    >>> print class_info['total_size']
 
212
    0
 
213
 
167
214
 
168
215
=== Drivers and Driver Queries ===
169
216