How to add component to a test case using API? - kiwi-tcms

I created a test case using tcms_api
test_case = rpc_client.TestCase.create({
'summary': 'My testing',
'product': 2,
'category': 2,
'priority': 1,
'is_automated': True,
'text': 'my first test case',
'case_status': 2, # CONFIRMED
})
I wanted to add component to the test case, but could not find a sample or the syntax in API document. I tried the following with my guess and the update in change log:
rpc_client.TestCase.add_component(test_case['id'], [3, 6])
I got the error below. Can you please advise how to construct the query for component query? Thanks.
xmlrpc.client.Fault:
Fault -32603: 'Internal error: Component matching query does not exist.'

From the documentation the signature of this method is:
function:: XML-RPC TestCase.add_component(case_id, component_id)
The docs tell you that component_id is an int, not a list.
^^^^ scratch that, the documentation is slightly wrong.
The second parameter is a string which should be the component name!

Related

How to handle null or Non required column in json in Azure Logic App

sample api url: https://jsonplaceholder.typicode.com/posts
title is not a mandatory field in received json. It may or may not be part of each record.
When this field is missing in record, #{items('For_each')['title']} this throws an exception.
I want the value of myVariable to set as 'N/A' in that case. How do i do this?
I make the assumption that this is an array and that you have a set schema in the HTTP trigger. If the schema is set, make sure you remove Title as a required field.
Using these asumptions you should be able to do the following with Coalesce()
If Title now is not present in the body of the HTTP request the Title will be equal to 'N/A'
Using postman to test, note, the result is backward as it is the first object sent in my array.
Cause you url data all have the title, so I test with When a HTTP request is recived trigger to get the json data.
In this situation the data could only be like this:
{
"userId": 1,
"id": 2,
"body": "xxxxx"
}
not like the below one:
{
"userId": 1,
"id": 2,
"title":,
"body": "xxxxxxxxx"
}
I test with the first one, it did show the error message: property 'title' doesn't exist,. So here is my solution, after the action Set variable, add an action to set the variable you want and set the action run after Set variable has failed like the below picture.
After configuration, if the title doesn't exist, it will be set as N/A as you want.
Hope this could help you, if this is not what you want or you have other questions, please let me know.

react-router transitionTo: Invariant Violation: Missing "splat" parameter for path

I am using react-router with react.
I need to use query strings in my url like this:
let url = '/some/path/legal?id=2&name=QA_3%206*6*6';
this.context.router.transitionTo(url);
However, it does not do the redirect and throws an error:
Unhandled promise rejection Error: Invariant Violation: Missing "splat" parameter for path "/some/path/legal?id=2&name=QA_3%206*6*6"
Seems that the splat (*) is not allowed in the query strings?
I haven't used this old version of react-router, but it looks like the signature is:
routeName (string), params (object), query (unused)
So try:
this.transitionTo('/some/path/legal', { id: 2, name: 'QA_3%206*6*6' });
I would have thought it'd be a query but it seems that is unused.
Edit, OP tested and seems it's used, so:
this.transitionTo('/some/path/legal', null, { id: 2, name: 'QA_3%206*6*6' });
Perhaps think about update to at least v1, which doesn't use transitionTo anymore. See https://github.com/rackt/react-router/blob/master/upgrade-guides/v1.0.0.md#navigation-mixin.
For me, it was just a case of explicitly setting the splat parameter when transitioning to the new route:
router.transitionTo('help', {splat: 'content'});
given my route was:
<Route path="help/*" handler={HelpPage}/>

intern functional tests using remote web driver are all failing

Background:
After getting my infrastructure properly setup to have intern run functional tests against a set of VMs. All machines exist on the same network.
I am using intern to run my functional tests.
*not using sauce labs but rather selenium grid 2 - hub & nodes.
Problem:
All functional test cases are failing.
Error: Student Name field should contain same string that was entered:
expected '' to equal 'qwerty' AssertionError: Student Name field
should contain same string that was entered: expected '' to equal
'qwerty'
Observations:
I see the form field getting filled out, but when I do the assert - something as simple as get the text and match it with expected input, I get the error response 7.
What I've Tried
Here is the typical boiler plate for a functional test case.
studentName: function () {
return this.remote
.get('http://some.ip.addr:3000/#students')
.elementById('name')
.clickElement()
.type('qwerty')
.end()
.elementById('name')
.text()
.then(function(resultText){
assert.equal(resultText, 'qwerty', 'Student Name field should contain same string that was entered');
});
}
Other Notes:
Link to Status Response Codes that are mentioned above
The solution to the '' (empty string) being returned is to use:
.elementById('name')
.getAttribute('value')
instead of
.elementById('name')
text()
This was sent to me by a contact that works on the project. Here is his explanation:
Basically, .text() will not get the value of a form field, so you need
to use WebDriver's getAttribute()

Unable to populate Backbone collection with sinon + jasmine

I have the same problem that was asked here
the author of the question mentioned that he was able to solve it by using the standalone version of jasmine over the headless webkit.
In my tests i use only a standalone version of jasmine and still having the same problem.
Here is my code:
describe 'Shared Collections Specs', ->
describe 'Channel Collection', ->
describe 'When fetching channels', ->
responseFixture = null
channelCollection = null
server = null
beforeEach ->
channelCollection = new ChannelCollection()
responseFixture = [{id: 3, name: 'foo'}, {id: 1, name: 'bar'}, {id: 2, name: 'baz'}]
server = sinon.fakeServer.create()
server.respondWith('GET', 'enspoint/channels', [
200, {'Content-Type':'application/json'}, JSON.stringify responseFixture
])
afterEach ->
server.restore()
it 'should populate the collection', ->
channelCollection.fetch()
server.respond()
expect(channelCollection.length).toEqual responseFixture.length
The collection is always empty insted of expected length of 3 it fails with Expected 0 to equal 3.
I tried to use jasmine waits and runs as i thought there might be something async in the process but i'm getting the same result.
Any ideas?
Just an innocent observation, but there might be a typo in the URL "enspoint/channels" in your XHR fixture. For example, did you mean "endpoint/channels"?

Projecting specified fields within an array in MongoDB (missing ] error?)

In MongoDB, I understand that to project only specified fields in a collection, I would execute:
db.collection.find({}, {"field1": 1, "field2": 1})
But what would I do if I wanted to only project specified fields within an array in a collection? The only way I can think would be this:
db.collection.find({field1: [arrayfield1: 1, arrayfield2: 1, arrayfield3: 1]})
But I get "SyntaxError: missing ] after element list (shell):1".
I've tried this as well:
db.collection.find({field1: [arrayfield1: 1], [arrayfield2: 1], [arrayfield3: 1]})
And get the same error. Can anyone tell me what I'm doing wrong? Because I can't figure it out. Or if I'm on the completely wrong track?
(I'm aware that the error says "element list," and I believe it should be a field list or something to that extent, so I suspect this is not the correct way to go about what I'm trying to do.)
I figured it out. The answer was dot notation. This did the trick:
db.colletion.find({}, { "array.arrayfield1" : 1, "array.arrayfield2" : 1, "array.arrayfield3" : 1 })

Resources