Testrail API Ruby add_result_for_case error - ruby

I am executing the code below as a cucumber step. The test case id is
C70. I tried a run ID and it gave the same error.
The code and error are below -
-----------------
require 'testrail-ruby'
client = TestRail::APIClient.new('https://xxxx.testrail.net')
client.user = 'xxxxxxxxxx.com'
client.password = 'xxxxxx'
r = client.send_post(
'add_result_for_case/C270',
{ :status_id => 1, :comment => 'This test worked fine!' }
)
puts r
The Error:
TestRail API returned HTTP 400 ("Field :run_id is not a valid ID.")
What am I doing wrong? I have researched this topic and have not resolved it Please advise....

I found my problem . I should have used the full Test Case ID. The ID that found when running the actual test case . The issue is resloved.

Extra suggestion.
Do not use characters other than numbers when giving the ID information. For example, when giving the case Id, it shows up as C270 in Testrail. But you have to give it as 270 in Api. In another example, let your RunId be R150. You only need to give it as 150.

Related

Django REST with pytest fixture integrity error

I am trying to create a fixture with pytest, but when I run it, I get the following error:
django.db.utils.IntegrityError: NOT NULL constraint failed: authtoken_token.user_id
I found information on it, but I am not sure how to handle it when it comes to fixtures.
My code:
#pytest.fixture
def client(db):
api_client = APIClient()
token = Token.objects.get_or_create(user__username='testuser')
api_client.credentials(HTTP_AUTHORIZATION='Token ' + token.key)
return api_client
#pytest.mark.django_db
def test_get_list_test(client):
url = reverse('api/lists')
response = client.get(url)
assert response.status_code == 200
Generally speaking, i don't think your error related to pytest here.
I think the main issue here related to django db migrations look here
So first, Make sure you fix it, regardless to any framework (pytest)
django.db.utils.IntegrityError: NOT NULL constraint failed: authtoken_token.user_id
And after you have successfully validated that the error passed away (check manually also), try to run the fixture.

google-api-ruby-client: Request serialization results in empty requests

replacement_requests = [
Google::Apis::DocsV1::ReplaceAllTextRequest.new(contains_text: "{{name}}", replace_text: "Joe"),
Google::Apis::DocsV1::ReplaceAllTextRequest.new(contains_text: "{{age}}", replace_text: "34"),
Google::Apis::DocsV1::ReplaceAllTextRequest.new(contains_text: "{{address}}", replace_text: "Westwood"),
]
batch_request = Google::Apis::DocsV1::BatchUpdateDocumentRequest.new(requests: replacement_requests)
Given the above code, when I pass this BatcUpdateDocumentRequest instance into my service.batch_update_document function, I receive a 400 bad request. This seems to be related to the way the batch request is being serialized.
To illustrate, if we call batch_request.to_json we receive the following:
"{\"requests\":[{},{},{}]}"
This tells me that something is going wrong during serialization, however my code seems rather canonical.
Any thoughts on why my requests are failing to be serialized?
You want to use the replaceAllText request using google-api-client with ruby.
You have already been able to put and get values for Google Document using Google Docs API.
If my understanding is correct, how about this modification? In your script, the created request body is {"requests":[{},{},{}]}. By this, the error occurs. Please modify the script as follows.
Modification points:
Use Google::Apis::DocsV1::SubstringMatchCriteria for contains_text of Google::Apis::DocsV1::ReplaceAllTextRequest
Use Google::Apis::DocsV1::Request for Google::Apis::DocsV1::ReplaceAllTextRequest.
By above modification, the request body is created.
Modified script:
text1 = Google::Apis::DocsV1::SubstringMatchCriteria.new(text: "{{name}}")
text2 = Google::Apis::DocsV1::SubstringMatchCriteria.new(text: "{{age}}")
text3 = Google::Apis::DocsV1::SubstringMatchCriteria.new(text: "{{address}}")
req1 = Google::Apis::DocsV1::ReplaceAllTextRequest.new(contains_text: text1 , replace_text: "Joe")
req2 = Google::Apis::DocsV1::ReplaceAllTextRequest.new(contains_text: text2, replace_text: "34")
req3 = Google::Apis::DocsV1::ReplaceAllTextRequest.new(contains_text: text3, replace_text: "Westwood")
replacement_requests = [
Google::Apis::DocsV1::Request.new(replace_all_text: req1),
Google::Apis::DocsV1::Request.new(replace_all_text: req2),
Google::Apis::DocsV1::Request.new(replace_all_text: req3)
]
batch_request = Google::Apis::DocsV1::BatchUpdateDocumentRequest.new(requests: replacement_requests)
# result = service.batch_update_document(document_id, batch_request) # When you request with "batch_request", you can use this.
Request body:
When above script is run, the following request body is created.
{"requests":[
{"replaceAllText":{"containsText":{"text":"{{name}}"},"replaceText":"Joe"}},
{"replaceAllText":{"containsText":{"text":"{{age}}"},"replaceText":"34"}},
{"replaceAllText":{"containsText":{"text":"{{address}}"},"replaceText":"Westwood"}}
]}
Note:
When the error related to the authorization occurs, please confirm the scopes and whether Docs API has been enabled.
References:
Method: documents.batchUpdate
ReplaceAllTextRequest
If this didn't work, I apologize.

Can't send a message from xmpp4r?

I'm trying to test sending a message to one jid account by using xmpp4r:
require 'xmpp4r'
include Jabber
jid = JID::new('alice#wonderland.lit')
password = 'secr3t'
cl = Client::new(jid)
cl.connect('166.78.7.179')
cl.auth(password)
cl.send(Presence.new)
to = 'arthur#wonderland.lit'
subject = 'XMPP4R test'
body = 'Hi, this is a XMPP4R test'
m = Message::new( to, body ).set_type(:chat).set_id('1').set_subject(subject)
cl.send m
But I always get the following exception:
/home/subout/.rvm/gems/ruby-1.9.3-p374#subout/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:118:in `rescue in auth': closed stream (Jabber::ClientAuthenticationFailure)
from /home/subout/.rvm/gems/ruby-1.9.3-p374#subout/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:108:in `auth'
from send_message2.rb:9:in `<main>'
First of all, would you please add Jabber::debug = true setting
before cl.connect and post output here?
Secondly, it looks like there is a problem with XMPP server (are you sure it’s running at
'166.78.7.179'?)
And, the last but not the least, why do you decide
to use “obsolete” xmpp4r rather than it’s modern successor
Blather?

MtGox Gem Failing to Login

I am trying to use the MtGox gem to cancel orders, however, I only get the following error message:
{"error":"Must be logged in"}
I am using the following code to make the call:
MtGox.configure {|c| c.key = user.mtgox_key; c.secret = user.mtgox_secret}
MtGox.cancel('oid'=>'a3c348d9-36c3-4927-b84d-206f421907f5', 'type'=>1)
I have also tried getting all of the open orders for a specific user using the following:
MtGox.post('/api/0/getOrders.php', {})
Alas, every call returns the same error message. Am I missing something?
This issue was resolved by using a smaller nonce for v1 api calls. Interestingly, a nonce of length 22 was causing subsequent v0 api calls to fail, but not subsequent v1 calls. I compute my nonce by simply using:
var nonce = ((new Date()).getTime()*1000).toString(); // microseconds since epoch

Reporting in Microsoft AdCenter (Sandbox) - RoR

I am using AdCenter API for my RoR application. I searched a lot on Internet to find example of ruby code to fetch account performance report using API, But didn't get.. Now I have written following code but submitGenerateReport returns nil
Here is my code.
report_request = AccountPerformanceReportRequest.new
start_date = 10.days.ago.strftime("%Y-%m-%d")
end_date = Time.zone.now.strftime("%Y-%m-%d")
scope = AccountReportScope.new
scope.accountIds = [AppConfig.adcenter['accountId']]
# Specify the format of the report.
report_request.format = 'Xml'
report_request.returnOnlyCompleteData = false
report_request.language = 'English'
report_request.reportName = "My Account Report"
report_request.aggregation = 'Daily'
report_request.time = ReportTime.new(start_date, end_date)
report_request.columns = %w[ AccountName AccountName GregorianDate CurrentMaxCpc Impressions Clicks ]
report_request.scope = scope
report_request.filter = nil
report = SubmitGenerateReportRequest.new(report_request)
# Returns nil
puts response = svc.submitGenerateReport(report)
I have campaigns, adgroups as well as ads in specified account.
Can anyone please guide me where I am wrong or give some example of reporting adcenter through api using ruby?
Thanks in advance
Got the solution...
The time was not in right format so, start time and end time was unrecognisable in soap request. SOAP debugging helped me a lot..

Resources