Testopia:Documentation:XMLRPC:Query Examples

From MozillaWiki
Jump to: navigation, search

Back to Testopia:Documentation:XMLRPC

Query Examples

Simple Queries

Overview

Simple queries use a list of attribute name/value pairs to seach for a set of records.

The name/value pairs in a list are combined with the logical AND operator to form more complex queries.

To find a test plan with an id of 1:

Perl

$proxy->call('TestPlan.list', {plan_id=>1});

To find a test case run with a build id of 1 and a case id of 1 and a run id of 1:

Perl

$proxy->call('TestCaseRun.list', {build_id=>1, case_id=>1, run_id=>1});

Simple Attributes

  • case_status_id
  • category
  • category_id
  • priority_id
  • component
  • isautomated
  • case_run_status_id
  • default_product_version
  • run_product_version
  • type_id
  • build
  • build_id
  • environment_id
  • milestone
  • env_products
  • env_categories
  • env_elements
  • env_properties
  • env_expressions
  • case_status
  • priority
  • environment
  • plan_type
  • case_run_status

Static Text (String) Queries

String queries require two name/value pairs. There first value pair is the attribute name and the value being search for. The second name/value pair is the attribute name appended with the keyword, _type, and the value is the type of search operation being conducted.

To find a test plan with the name, "Unit Test Plan":

Perl

$proxy->call('TestPlan.list', {name=>'Unit Test Plan', name_type='anyexact'});

Static text attributes

  • author
  • manager
  • default_tester
  • assignee
  • testedby
  • case_summary
  • summary
  • tcaction
  • tceffect
  • script
  • requirement
  • name
  • plan_text
  • environment
  • notes
  • env_value_selected

Valid Search Operations

  • equals
  • notequals
  • isnull
  • isnotnull
  • lessthan
  • greaterhthan
  • regexp
  • noteregexp
  • anywords
  • allwords
  • nowords

Special Queries

The id attributes for TestCase, TestPlan, and TestRun have respective name/value pairs for creating static-text-like searches. In other words, you can use same search operations defined for static text attributes.

  • case_id uses caseidtype
  • plan_id uses planidtype
  • run_id uses runidtype

To find all Test Plans with id less than 200:

Perl

$proxy->call('TestPlan.list', {plan_id => 200, planidtype => "lessthan"})

Queries Using Binary Charts

Overview

Queries are based on Bugzilla's advanced searching using boolean charts.

This type of query can be found near the bottom of the "Advanced Search" tab on http://company.com/bugzilla/query.cgi

Charts are simple tables with rows and columns.

Each row has three columns:

  • Attribute
  • Operation
  • Value


Simple queries for a TestPlan might be:

Attribute Operation Value
plan_id equals 1
name anywords "Second"


Multiple rows are combined with a logical AND operation.

Advanced: Multiple charts are combined with a logical OR operation.

Attributes

  • Attributes are used to represent the lefthand-side (LHS) of given query operation
  • Attributes are the available public field names for any given object
    • See the API Object documentation for a list of attributes of each object
  • Currently there are two attribute data types: integers and strings

Values

  • Values are used to represent the righthand-side (RHS) of a given query operation
  • Values must be match their respective attribute's datatype

Operations

  • equals
  • notequals
  • isnull
  • isnotnull
  • lessthan
  • greaterhthan
  • regexp
  • noteregexp
  • anywords
  • allwords
  • nowords

Coding

In Bugzilla:

  • Attributes are called fields
  • Operations are called types

The keywords, field, type, and value are appended with "chart#-row#-column#" to create keys for the hashmap passed as our query.

The first row in chart 0 would have the following columns:

field0-0-0
type0-0-0
value0-0-0

Perl

$query = {
          "field0-0-0" => "name",
          "type0-0-0"  => "anywords",
          "value0-0-0" => "Second"
         };

Java

HashMap<String, Object> query = new HashMap<String, Object>();
query.put("field0-0-0", "name");
query.put("type0-0-0",  "anywords");
query.put("value0-0-0", "Second");




Back to the Testopia Main Page