class Testlink::Client::TestlinkAPIClient

Attributes

key[RW]
uri[RW]

Public Class Methods

new(uri, key) click to toggle source
# File lib/testlink/client.rb, line 15
def initialize uri, key
  @key = key
  @uri = get_api_uri uri
end

Public Instance Methods

add_test_case_keywords(keywords) click to toggle source
# File lib/testlink/client.rb, line 244
def add_test_case_keywords keywords

  # keywords is a map key: testcaseexternalid, values: array of keyword name
  input = { "keywords" => keywords }
  get_result "tl.addTestCaseKeywords", input
end
check_dev_key() click to toggle source
# File lib/testlink/client.rb, line 44
def check_dev_key

  get_result "tl.checkDevKey"
end
get_api_uri(uri) click to toggle source
# File lib/testlink/client.rb, line 21
def get_api_uri uri
  uri + "/lib/api/xmlrpc/v1/xmlrpc.php"
end
get_first_level_test_suites_for_test_project(tprojectid) click to toggle source
# File lib/testlink/client.rb, line 172
def get_first_level_test_suites_for_test_project tprojectid

  input = {"testprojectid" => tprojectid }
  get_result "tl.getFirstLevelTestSuitesForTestProject", input
end
get_last_execution_result_by_tcid(tplanid, tcid) click to toggle source
# File lib/testlink/client.rb, line 57
def get_last_execution_result_by_tcid tplanid, tcid

  input = { "testplanid" => tplanid,
            "testcaseid" => tcid }
  get_result "tl.getLastExecutionResult", input
end
get_latest_build_for_test_plan(tplanid) click to toggle source
# File lib/testlink/client.rb, line 50
def get_latest_build_for_test_plan tplanid

  input = {"testplanid" => tplanid }
  get_result "tl.getLatestBuildForTestPlan", input
end
get_project_keywords(tprojectid) click to toggle source
# File lib/testlink/client.rb, line 78
def get_project_keywords tprojectid

  input = { "testprojectid" => tprojectid }
  get_result "tl.getProjectKeywords", input
end
get_project_test_plans(tprojectid) click to toggle source
# File lib/testlink/client.rb, line 71
def get_project_test_plans tprojectid

  input = { "testprojectid" => tprojectid }
  get_result "tl.getProjectTestPlans", input
end
get_projects() click to toggle source
# File lib/testlink/client.rb, line 65
def get_projects
  
 get_result "tl.getProjects" 
end
get_result(method, input = {}) click to toggle source
# File lib/testlink/client.rb, line 26
def get_result method, input = {}
  connection = XMLRPC::Client.new_from_uri @uri
  input["devKey"] = @key

  result = connection.call2 method, input
  if result[0]
    if defined? result[1][0] and !result[1][0].nil? and result[1][0].has_key? "message"
      warn result[1][0]["message"]
      false
    else
      result[1]
    end
  else
    raise MethodCallFailed, "Method call to XMLRPC API failed."
  end
end
get_test_case(tcid = nil, tcexternalid = nil) click to toggle source
# File lib/testlink/client.rb, line 179
def get_test_case tcid = nil, tcexternalid = nil

  if tcexternalid.nil?
    input = { "testcaseid" => tcid }
  else
    input = { "testcaseexternalid" => tcexternalid }
  end
  get_result "tl.getTestCase", input
end
get_test_case_by_tcexternalid(tcexternalid) click to toggle source
# File lib/testlink/client.rb, line 196
def get_test_case_by_tcexternalid tcexternalid

  get_test_case nil, tcexternalid
end
get_test_case_by_tcid(tcid) click to toggle source
# File lib/testlink/client.rb, line 190
def get_test_case_by_tcid tcid

  get_test_case tcid
end
get_test_case_id_by_name(tcasename, tsuitename = "", tprojectname = "", tcasepathname = "") click to toggle source
# File lib/testlink/client.rb, line 162
def get_test_case_id_by_name tcasename, tsuitename = "", tprojectname = "", tcasepathname = ""

  input = { "testcasename" => tcasename,
            "testsuitename" => tsuitename,
            "testprojectname" => tprojectname,
            "testcasepathanme" => tcasepathname }
  get_result "tl.getTestCaseIDByName", input
end
get_test_case_keywords(tcid = "", tcexternalid = "") click to toggle source
# File lib/testlink/client.rb, line 85
def get_test_case_keywords tcid = "", tcexternalid = ""

  if tcexternalid.nil?
    input = { "testcaseexternalid" => tcexternalid }
  else
    input = { "testcaseid" => tcid }
  end
  get_result "tl.getTestCaseKeywords", input
end
get_test_case_keywords_by_tcexternalid(tcexternalid) click to toggle source
# File lib/testlink/client.rb, line 101
def get_test_case_keywords_by_tcexternalid tcexternalid
  get_test_case_keywords "", tcexternalid
end
get_test_case_keywords_by_tcid(tcid) click to toggle source
# File lib/testlink/client.rb, line 96
def get_test_case_keywords_by_tcid tcid
  get_test_case_keywords tcid
end
get_test_cases_for_test_plan(tplanid, buildid = nil, platformid = nil, testcaseid = nil, keywordid = nil, keywords = nil, executed = nil, assignedto = nil, executestatus = nil, executiontype = nil, getstepinfo = false, details = nil) click to toggle source
# File lib/testlink/client.rb, line 128
def get_test_cases_for_test_plan tplanid, buildid = nil, platformid = nil, testcaseid = nil, keywordid = nil, keywords = nil, executed = nil, assignedto = nil, executestatus = nil, executiontype = nil, getstepinfo = false, details = nil

  input = Hash.new
  input["testplanid"] = tplanid
  input["buildid"] = buildid unless buildid.nil?
  input["platformid"] = platformid unless platformid.nil?
  input["testcaseid"] = testcaseid unless testcaseid.nil?
  input["keywordid"] = keywordid unless keywordid.nil?
  input["keywords"] = keywords unless keywords.nil?
  input["executed"] = executed unless executed.nil?
  input["assignedto"] = assignedto unless assignedto.nil?
  input["executestatus"] = executestatus unless executestatus.nil?
  input["executiontype"] = executiontype unless executiontype.nil?
  input["getstepinfo"] = getstepinfo unless getstepinfo.nil?
  input["details"] = details unless details.nil?

  get_result "tl.getTestCasesForTestPlan", input
end
get_test_cases_for_test_suite(tsuiteid, deep=true, details = "") click to toggle source
# File lib/testlink/client.rb, line 147
def get_test_cases_for_test_suite tsuiteid, deep=true, details = ""

  input = { "testsuiteid" => tsuiteid, 
            "deep" => deep,
            "details" => details }
  get_result "tl.getTestCasesForTestSuite", input
end
get_test_plan_by_name(tprojectname, tplanname) click to toggle source
# File lib/testlink/client.rb, line 113
def get_test_plan_by_name tprojectname, tplanname

  input = { "testprojectname" => tprojectname,
            "testplanname" => tplanname }
  get_result "tl.getTestPlanByName", input
end
get_test_project_by_name(tprojectname) click to toggle source
# File lib/testlink/client.rb, line 106
def get_test_project_by_name tprojectname

  input = { "testprojectname" => tprojectname }
  get_result "tl.getTestProjectByName", input
end
get_test_suite_by_id(tsuiteid) click to toggle source
# File lib/testlink/client.rb, line 202
def get_test_suite_by_id tsuiteid

  input =  { "testsuiteid" => tsuiteid }
  get_result "tl.getTestSuiteByID", input
end
get_test_suites_for_test_plan(tplanid) click to toggle source
# File lib/testlink/client.rb, line 121
def get_test_suites_for_test_plan tplanid

  input = { "testplanid" => tplanid }
  get_result "tl.getTestSuitesForTestPlan", input
end
get_test_suites_for_test_suite(tsuiteid) click to toggle source
# File lib/testlink/client.rb, line 155
def get_test_suites_for_test_suite tsuiteid

  input = { "testsuiteid" => tsuiteid }
  get_result "tl.getTestSuitesForTestSuite", input
end
get_user_by_id(userid) click to toggle source
# File lib/testlink/client.rb, line 209
def get_user_by_id userid

  input =  { "userid" => userid }
  get_result "tl.getUserByID", input
end
remove_test_case_keywords(keywords) click to toggle source
# File lib/testlink/client.rb, line 252
def remove_test_case_keywords keywords

  input = { "keywords" => keywords }
  get_result "tl.removeTestCaseKeywords", input
end
set_test_case_execution_type(tcid, version, tprojectid, executiontype) click to toggle source
# File lib/testlink/client.rb, line 234
def set_test_case_execution_type tcid, version, tprojectid, executiontype

 input = { "testcaseid" => tcid,
           "version" => version,
           "testprojectid" => tprojectid,
           "executiontype" => executiontype }
get_result "tl.setTestCaseExecutionType", input 
end
update_test_case(tcid, version = "", testcasename = "", summary = "", preconditions = "", steps = "", importance = "", executiontype = "", status = "", active = "", estimatedexecduration = "", user = "") click to toggle source
# File lib/testlink/client.rb, line 216
def update_test_case tcid, version = "", testcasename = "", summary = "", preconditions = "", steps = "", importance = "", executiontype = "", status = "", active = "", estimatedexecduration = "", user = ""

  input = { "testcaseid" => tcid,
            "version" => version,
            "testcasename" => testcasename,
            "summary" => summary,
            "preconditions" => preconditions,
            "steps" => steps,
            "importance" => importance,
            "executiontype" => executiontype,
            "status" => status,
            "active" => active,
            "estimatedexecduration" => estimatedexecduration,
            "user" => user }
  get_result "tl.updateTestCase", input
end