HP-ALM Adding Test Cases With REST API - testing

I'm looking to automate adding new test cases into HP-ALM using the REST API. I didn't find anything in the documentation to help me achieve this and I was wondering if anyone else had any success with it.

The API documentation provided through ALM is very helpful.
1) authenticate session
2) capture Cookie
3) create test (See below - FROM ALM DOCUMENTATION)
use the entity type you want to create and specify the appropriate fields.
Example with XML
POST /qcbin/rest/domains/{domain}/projects/{project}/defects HTTP/1.1
Content-Type: application/xml
Accept: application/xml
Cookie: QCSession=xxx; LWSSO_COOKIE_KEY=xxx
Data
<Entity Type="defect">
<Fields>
<Field Name="detected-by">
<Value>henry_tilney</Value>
</Field>
<Field Name="creation-time">
<Value>2010-03-02</Value>
</Field>
<Field Name="severity">
<Value>2-Medium</Value>
</Field>
<Field Name="name">
<Value>Returned value not does not match value in database.</Value>
</Field>
</Fields>
</Entity>
Example with JSON
POST /qcbin/rest/domains/{domain}/projects/{project}/defects HTTP/1.1
Content-Type: application/json
Accept: application/json
Cookie: QCSession=xxx; LWSSO_COOKIE_KEY=xxx
Data
{"Fields":[{"Name":"detected-by","values":[{"value":"henry_tilney"}]}, {"Name":"creation-time","values":[{"value":"2010-03-02"}]},{"Name":"severity","values":[{"value":"2-Medium"}]},{"Name":"name","values":[{"value":"Returned value not does not match value in database.</ "}]}]}
Example XML I Have Used for Test Entity
<Entity Type="test">
<Fields>
<Field Name="name">
<Value>MY TEST CASE</Value>
</Field>
<Field Name="description">
<Value>Test created from api</Value>
</Field>
<Field Name="owner">
<Value>roglesby</Value>
</Field>
<Field Name = "subtype-id">
<Value>VAPI-XP-TEST</Value>
</Field>
<Field Name = "parent-id">
<Value>6209</Value>
</Field>
</Fields>
</Entity>

I have created a small module to send REST requests to HP ALM using python. For instance I am using the following command:
myCreate = self.nSession.post(entUrl, headers=self.header, data=xml_data)
After a correct Session is established, then I am using a simple POST action. The value in parenthesis are respectively:
entUrl = '{0}/rest/domains/{1}/projects/{2}'.format(self.server, self.domain, self.project) + you have to add the entity you want to create --> tests for instance.
{server}/qcbin/rest/domains/{domain}/projects/{project}/tests
headers is a dictionary containing all the headers needed to maintain the connection opened.
data is containing an xml or a JSON file format with all the information to create a test (for instance)
Hope this can help other users (since the question is quite old). Have a nice day.

Related

How to reference a planning type in a plan

I have a custom odoo module, which extends some existing modules like hr. I want to create an onboarding plan with several predefined tasks in it.
This is my plan acitivity type xml which works at it should. If I update the applikation with this file, I get the desired tasks in the planning types overview.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_plan_activity_type_create_work_contract" model="hr.plan.activity.type">
<field name="activity_type_id" ref="mail.mail_activity_data_todo"/>
<field name="responsible">manager</field>
<field name="summary">Create work contract</field>
<field name="note">Create the work contract for the employee.</field>
</record>
<record id="hr_plan_activity_type_employee_model_in_erp" model="hr.plan.activity.type">
<field name="activity_type_id" ref="mail.mail_activity_data_todo"/>
<field name="responsible">manager</field>
<field name="summary">Employee model in ERP</field>
<field name="note">Complete the employee model in ERP (AHV, Banking, etc.)</field>
</record>
</odoo>
This is my plan.xml which should create a plan with the activity types. The creation of the plan works, but if I reference the activity types, I'll get an error message.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Onboarding -->
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids"
eval="[(6,0,[ref('mycompany.hr_plan_activity_type_employee_model_in_erp')])]"/>
<field name="plan_activity_type_ids"
eval="[(4,0,[ref('mycompany.hr_plan_activity_type_create_work_contract')])]"/>
</record>
</odoo>
In the manifest.py file I first load the plan.activity.type.xml and then the plan.xml so this shouldn't be a problem.
This is the error message I get when I try to upgrade my customized module mycompany:
File "C:\Program Files (x86)\Odoo 13.0e\server\odoo\addons\base\models\ir_model.py", line 1670, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
odoo.tools.convert.ParseError: "External ID not found in the system: hr.plan.activity.type.hr_plan_activity_type_create_work_contract" while parsing file:/c:/users/myuser/appdata/local/openerp%20s.a/odoo/addons/13.0/mycompany/data/hr/plan.xml:2, near
<odoo>
<!-- Onboarding -->
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids" ref="hr.plan.activity.type.hr_plan_activity_type_create_work_contract"/>
</record>
Does anyone have any ideas?
String identifier stored in ir.model.data, can be used to refer to a record regardless of its database identifier during data imports or export/import roundtrips.
External identifiers are in the form module.id (e.g. account.invoice_graph). From within a module, the module. prefix can be left out.
Sometimes referred to as xml id or xml_id as XML-based Data Files make extensive use of them.
In your example you used model_name.id which probably does not exist in the database, to reference hr_plan_activity_type_create_work_contract record you just need to replace the model name with the module name.
I can see from the log message that the module name is mycompany, try to replace the model name with mycompany:
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids" ref="mycompany.hr_plan_activity_type_create_work_contract"/>
</record>
Update:plan_activity_type_ids is an x2many field
Use the special commands format to set the x2many field values:
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids" eval="[(6,0,[ref('mycompany.hr_plan_activity_type_create_work_contract')])]"/>
</record>
Edit: Only the first one shows up in the GUI
To replaces all existing records in the set by the ids list (using '(6, 0, ids)') you can provide a list of ids inside the triplet. You can find an example in res_partner_demo.xml inside the base module.
Example:
<field name="plan_activity_type_ids" eval="[(6,0,[ref('mycompany.hr_plan_activity_type_employee_model_in_erp'), ref('mycompany.hr_plan_activity_type_create_work_contract')])]"/>
To add an existing record of id id to the set (using (4, id)) you need to provide one id for each triplet. You can find an example in base_groups.xml inside the base module.
Example:
<field name="plan_activity_type_ids" eval="[(4,ref('mycompany.hr_plan_activity_type_employee_model_in_erp')), (4,ref('mycompany.hr_plan_activity_type_create_work_contract'))]"/>
Your ref ids are wrong. hr.plan.activity.type.hr_plan_activity_type_create_work_contract is wrong. You get only one . in a reference. its [<module_name>.]ext_id_of_object.
If you reference the object from the same module you don't have to use module name.part
If you can see the database tables. then things you are referencing are in table ir_model_data
So if the thing you are referencing is in your own model then you cant use just hr_plan_activity_type_create_work_contract as a reference or your_model_name.hr_plan_activity_type_create_work_contract

Is it normal fields are not updated after installing modules?

I'm developping a module on OpenERP 7.
It is a very simple code : it has only 1 new field (or column) in python file, and an xpath in the xml. I know it works because one time it was succesfully installed
When I try to install/update my module with the module interface, sometimes the field is added/updated to OpenERP, but sometimes no.
I tried to start/stop and restart Openerp before and after installing my module, but I don't know if it has consequences. I don't have errors or useful thing in the logs.
So fields don't add/update but xml update everytime... Does anyone have an idea of what's going on and a solution ?
python code:
# -*- coding: utf-8 -*-
from openerp.osv import fields, osv
class StockPickingIn(osv.osv):
_name = "stock.picking.in"
_inherit = "stock.picking.in"
_columns = {
'adquat_ack_recep': fields.boolean('Accusé de réception'),
}
xml code:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="view_picking_in_form_adquat" model="ir.ui.view">
<field name="name">stock.picking.in.form.adquat</field>
<field name="model">stock.picking.in</field>
<field name="inherit_id" ref="stock.view_picking_in_form"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='stock_journal_id']" position="after">
<field name="adquat_ack_recep" />
</xpath>
</field>
</record>
<record id="view_picking_in_tree_adquat" model="ir.ui.view">
<field name="name">stock.picking.in.tree.adquat</field>
<field name="model">stock.picking.in</field>
<field name="inherit_id" ref="stock.view_picking_in_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='state']" position="after">
<field name="adquat_ack_recep" />
</xpath>
</field>
</record>
</data>
</openerp>
I think it works to update fields with Command line -u !
But my other problem is not solved : I dont have empty checkboxes in form view
And in form view i can't have this checkbox checked :
I click on edit, i check it and save : the checkbox come back to empty !
I saw in the database the value is saved as true or false, but it's not displayed on the interface
You should see the following error
ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!
Because adquat_ack_recep is defined in stock.picking and you add it to stock.picking.in form.
You need to inherit from stock.picking.in.
_inherit = "stock.picking.in"
Edit:
Add adquat_ack_recep field to both models stock.picking and stock.picking.in (stock.picking.in read method was overitten to read values from stock.picking model). Take a look at fields not saving problem
Problem may arises due two instances running at same time. make sure you run single instance. you can also update module through command line this may solve your issue
refer this link for module updation through command line.

Use Solr to index/search txt file content

I'm making a study to compare different search platforms' performance over Twitter's tweets. For my purpose I have collected a set of tweets (around 50,000) and saved them in a single text (.txt) file in a format similar to the following:
Tweet ID User Tweet Content Tweet Time-stamp
The data would look like this:
31261817690923008 username1 tweet 1 content goes here 1482180069
31132193287839744 username2 tweet 2 content goes here 1274400000
Now, using Solr 6.3.0, is it possible to index each line of content separately? Instead, should I use XML or JSON? or do I have to store each line (tweet) in a different file?
You can use the CSV Update Handler, which will result in a single document for each row.
To adjust the parsing to the structure you've used, you can use separator (TAB? %09) to provide the separator used between fields / columns, encapsulator to set the value used to encapsulate a single field value (it doesn't seem you've used any) and fieldnames to provide a proper field name for each column, unless they're in the first row - in that case set header to true (and don't provide fieldnames).
Assuming two things:
#1 You do not want to do an awful lot of coding for the data entry.
#2 Your text file is TAB or comma separated.
If so, you can easily turn it into an XML that can be added via the Admin interface.
A few things to keep in mind:
Enclose your data in <add> ... </add> blocks of a reasonable size. Ideally not 50K. Experiment a little.
Enclose each entry - line in your case in <doc> ... <doc>
Each column needs to have its own field as in
<field name="id"> ... </field>
<field name="username"> ... </field>
...
All need unique IDs.
For practical purposes, if you can open the textfile in a spreadsheet, add the tag columns in between your data and then concatenate the lines, it is relatively easy even if a little labour intensive for 50K.
A doc set of two would look something like:
<add>
<doc>
<field name="id"> ... </field>
<field name="user"> ... </field>
<field name="content"> ... </field>
<field name="time_stamp"> ... </field>
</doc>
<doc>
<field name="id"> ... </field>
<field name="user"> ... </field>
<field name="content"> ... </field>
<field name="time_stamp"> ... </field>
</doc>
</add>

How can I make the Odoo delivery address show inline on the order?

The partner_id has a context
{'show_address': 1}
Which I thought made the address show inline, but setting the context doesn't seem to accomplish the same thing on partner_shipping_id
<field name="partner_shipping_id" position="attributes">
<attribute name="context">{'show_address':1,'default_type':'delivery'}</attribute>
</field>
What am I missing?
Seems like I also need to make it always reload as the address is pulled in dynamically.
<field name="partner_shipping_id" position="attributes">
<attribute name="context">{'show_address':1,'default_type':'delivery'}</attribute>
<attribute name="options">{"always_reload": True}</attribute>
</field>
Yes you are right you missed
always_reload
Since the web client has already sent the record with a value it will not call name_get method. so the always_reload option in Many2one field forces to call name_get method explicitly

Avoiding Boxing/Unboxing on unknown input

I am creating an application that parses an XML and retrieves some data. Each xml node specifies the data (const), a recordset's column-name to get the data from (var), a subset of possible data values depending on some condition (enum) and others. It may also specify, alongside the data, the format in which the data must be shown to the user.
The thing is that for each node type I need to process the values differently and perform some actinons so, for each node, I need to store the return value in a temp variable in order to later format it... I know I could format it right there and return it but that would mean to repeat myself and I hate doing so.
So, the question: How can I store the value to return, in a temp variable, while avoiding boxing/unboxing when the type is unknown and I can't use generics?
P.S.: I'm designing the parser, the XML Schema and the view that will fill the recordset so changes to all are plausible.
Update
I cannot post the code nor the XML values but this is the XML structure and actual tags.
<?xml version='1.0' encoding='utf-8'?>
<root>
<entity>
<header>
<field type="const">C1</field>
<field type="const">C2</field>
<field type="count" />
<field type="sum" precision="2">some_recordset_field</field>
<field type="const">C3</field>
<field type="const">C4</field>
<field type="const">C5</field>
</header>
<detail>
<field type="enum" fieldName="some_recordset_field">
<match value="0">M1</match>
<match value="1">M2</match>
</field>
<field type="const">C6</field>
<field type="const">C7</field>
<field type="const">C8</field>
<field type="var" format="0000000000">some_recordset_field</field>
<field type="var" format="MMddyyyy">some_recordset_field</field>
<field type="var" format="0000000000" precision="2">some_recordset_field</field>
<field type="var" format="0000000000">some_recordset_field</field>
<field type="enum" fieldName ="some_recordset_field">
<match value="0">M3</match>
<match value="1">M4</match>
</field>
<field type="const">C9</field>
</detail>
</entity>
</root>
Have you tried using the var type? That way you don't need to know the type of each node. Also, some small sample of your scenario would be useful.