Polarion project
Initialization
The class can be instantiated like this:
pol = polarion.Polarion('http://example.com/polarion', 'user', 'password')
project = pol.getProject('Python')
Custom fields
When querying workitems using searchWorkitem()
or searchWorkitemInBaseline()
you can select what field to load using the ‘field_list’ paramater.
To select custom field using this list, use the following syntax: ´customFields.<key name>´.
The example loads the custom field ‘int_field’ and ‘string_field’.
project.searchWorkitem('type:task', field_list=['id', 'author', 'customFields.int_field', 'customFields.string_field'])
Project class
- class polarion.project.Project(polarion, project_id)
A Polarion project instance usable to access workitem, testruns and more. usually create by using the Polarion client.
- Parameters:
polarion – The polarion client instance
project_id – The project id, as can be found in the URL of the project
- createDocument(location, name, title, allowed_workitem_types, structure_link_role, home_page_content='')
Creates a new document
- Parameters:
location – Document location, the default location is _default
name – Name of the document
title – Document title
allowed_workitem_types – List of workitem types to be allowed inside the document
structure_link_role – Link role to be used when defining the document hierarchy between parents and children
home_page_content – Initial content of the document as HTML
- Returns:
New document
- createPlan(new_plan_name, new_plan_id, new_plan_template, new_plan_parent=None)
Create a plan based on a template, plan name and plan ID. :param new_plan_name: The new plan name :param new_plan_id: The new plan ID :param new_plan_template: The plan template to use. Defaults are ‘release’ and ‘iteration’. But this depends on
the project configuration.
- Parameters:
new_plan_parent – Optionally the parent plan
- Returns:
A new plan
- Return type:
- createTestRun(id, title, template_id)
Create a new test run with specified title from an existing test run template :param id: :param title: :param template_id:
- createWorkitem(workitem_type: str, new_workitem_fields=None)
Create a workitem based on the workitem type. :param workitem_type: The new workitem type :return: A new workitem :rtype: Workitem
- findUser(name)
Find a specific user by id or name in this project
- getDocument(location)
Get a document by location.
- Parameters:
location – Location of the document.
- Returns:
Document
- getDocumentLocations()
Get a list of all document locations. :return:string[]
- getDocumentSpaces()
Get a list al all document spaces. :return:string[]
- getDocumentsInSpace(space)
Get all documents in a space. :param space: Name of the space. :return: Document[]
- getEnum(enum_name)
Get the options for a selected enumeration
- Parameters:
enum_name – The first part of the enum name. Will be postpended by -enum.xml by Polarion API
- Returns:
A list of options for the enum
- Return type:
string[]
- getPlan(id: str)
Get a plan by string
- Parameters:
id – The ID of the project plan.
- Returns:
The request plan
- Return type:
- getTestRun(id: str)
Get a testrun by string
- Parameters:
id – The ID of the project testrun.
- Returns:
The request testrun
- Return type:
- getUsers()
Gets all users in this project
- getWorkitem(id: str)
Get a workitem by string
- Parameters:
id – The ID of the project workitem (PREF-123).
- Returns:
The request workitem
- Return type:
- searchPlan(query='', order='Created', limit=-1)
Query for available plans. This will return the polarion data structures.
- Parameters:
query – The query to use while searching
order – Order by
limit – The limit of plans, -1 for no limit
- Returns:
The search results
- Return type:
dict[]
- searchPlanFullItem(query='', order='Created', limit=-1)
Query for available plans. This will query for the plans and then fetch all result. May take a while for a big search with many results.
- Parameters:
query – The query to use while searching
order – Order by
limit – The limit of plans, -1 for no limit
- Returns:
The search results
- Return type:
Plan[]
- searchTestRuns(query='', order='Created', limit=-1)
Query for available test runs
- Parameters:
query – The query to use while searching
order – Order by
limit – The limit of test runs, -1 for no limit
- Returns:
The request testrun
- Return type:
Testrun[]
- searchWorkitem(query='', order='Created', field_list=None, limit=-1)
Query for available workitems. This will only query for the items. If you also want the Workitems to be retrieved, used searchWorkitemFullItem.
For retrieving custom field using field_list, use the following syntax: field_list=[‘customFields.<key of custom field here>’]
- Parameters:
query – The query to use while searching
order – Order by
field_list – list of fields to retrieve for each search result
limit – The limit of workitems, -1 for no limit
- Returns:
The search results
- Return type:
Workitem[] but only with the given fields set
- searchWorkitemFullItem(query='', order='Created', limit=-1)
Query for available workitems. This will query for the items and then fetch all result. May take a while for a big search with many results.
- Parameters:
query – The query to use while searching
order – Order by
limit – The limit of workitems, -1 for no limit
- Returns:
The search results
- Return type:
Workitem[]
- searchWorkitemFullItemInBaseline(baselineRevision, query='', sort='uri', limit=-1)
Query for available workitems in baseline. This will query for the items and then fetch all result. May take a while for a big search with many results.
- Parameters:
baselineRevision – The revision number of the baseline to search in
query – The query to use while searching
sort – Sort by
limit – The limit of workitems, -1 for no limit
- Returns:
The search results
- Return type:
Workitem[]
- searchWorkitemInBaseline(baselineRevision, query='', sort='uri', field_list=None, limit=-1)
Query for available workitems in a baseline. This will only query for the items. If you also want the Workitems to be retrieved, used searchWorkitemFullItemInBaseline.
For retrieving custom field using field_list, use the following syntax: field_list=[‘customFields.<key of custom field here>’]
- Parameters:
baselineRevision – The revision number of the baseline to search in
query – The query to use while searching
sort – Sort by
fieldList – list of fields to retrieve for each search result
limit – The limit of workitems, -1 for no limit
- Returns:
The search results
- Return type:
Workitem[] but only with the given fields set