Clean up Patch Add patch for 3.0.x synchronize with SVN git-svn-id: svn://10.0.0.236/trunk@246816 18797224-902f-48f8-a5cc-f745e15eee43
365 lines
7.4 KiB
Perl
365 lines
7.4 KiB
Perl
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
#
|
|
# The contents of this file are subject to the Mozilla Public
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
# except in compliance with the License. You may obtain a copy of
|
|
# the License at http://www.mozilla.org/MPL/
|
|
#
|
|
# Software distributed under the License is distributed on an "AS
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
# implied. See the License for the specific language governing
|
|
# rights and limitations under the License.
|
|
#
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
|
#
|
|
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
|
|
# Dallas Harken <dharken@novell.com>
|
|
|
|
package Bugzilla::WebService::Testopia::TestRun;
|
|
|
|
use strict;
|
|
|
|
use base qw(Bugzilla::WebService);
|
|
|
|
use Bugzilla::Product;
|
|
use Bugzilla::User;
|
|
use Bugzilla::Testopia::TestRun;
|
|
use Bugzilla::Testopia::Search;
|
|
use Bugzilla::Testopia::Table;
|
|
|
|
# Utility method called by the list method
|
|
sub _list
|
|
{
|
|
my ($query) = @_;
|
|
|
|
my $cgi = Bugzilla->cgi;
|
|
|
|
$cgi->param("current_tab", "run");
|
|
|
|
foreach (keys(%$query))
|
|
{
|
|
$cgi->param($_, $$query{$_});
|
|
}
|
|
|
|
my $search = Bugzilla::Testopia::Search->new($cgi);
|
|
|
|
# Result is an array of test run hash maps
|
|
return Bugzilla::Testopia::Table->new('run',
|
|
'tr_xmlrpc.cgi',
|
|
$cgi,
|
|
undef,
|
|
$search->query()
|
|
)->list();
|
|
}
|
|
|
|
sub get
|
|
{
|
|
my $self = shift;
|
|
my ($test_run_id) = @_;
|
|
|
|
$self->login;
|
|
|
|
#Result is a test run hash map
|
|
my $test_run = new Bugzilla::Testopia::TestRun($test_run_id);
|
|
|
|
if (not defined $test_run)
|
|
{
|
|
$self->logout;
|
|
die "Testrun, " . $test_run_id . ", not found";
|
|
}
|
|
|
|
if (not $test_run->canview)
|
|
{
|
|
$self->logout;
|
|
die "User Not Authorized";
|
|
}
|
|
|
|
$self->logout;
|
|
|
|
return $test_run;
|
|
}
|
|
|
|
sub list
|
|
{
|
|
my $self = shift;
|
|
my ($query) = @_;
|
|
|
|
$self->login;
|
|
|
|
my $list = _list($query);
|
|
|
|
$self->logout;
|
|
|
|
return $list;
|
|
}
|
|
|
|
sub create
|
|
{
|
|
my $self =shift;
|
|
my ($new_values) = @_;
|
|
|
|
$self->login;
|
|
|
|
my $test_run = Bugzilla::Testopia::TestRun->create($new_values);
|
|
|
|
$self->logout;
|
|
|
|
return $test_run->id;
|
|
}
|
|
|
|
sub update
|
|
{
|
|
my $self =shift;
|
|
my ($test_run_id, $new_values) = @_;
|
|
|
|
$self->login;
|
|
|
|
my $test_run = new Bugzilla::Testopia::TestRun($test_run_id);
|
|
|
|
if (not defined $test_run)
|
|
{
|
|
$self->logout;
|
|
die "Testrun, " . $test_run_id . ", not found";
|
|
}
|
|
|
|
if (not $test_run->canedit)
|
|
{
|
|
$self->logout;
|
|
die "User Not Authorized";
|
|
}
|
|
|
|
$test_run->set_environment($new_values->{'environment_id'});
|
|
$test_run->set_build($new_values->{'build_id'});
|
|
$test_run->set_summary($new_values->{'summary'});
|
|
$test_run->set_manager($new_values->{'manager_id'});
|
|
$test_run->set_plan_text_version($new_values->{'plan_text_version'});
|
|
$test_run->set_notes($new_values->{'notes'});
|
|
$test_run->set_product_version($new_values->{'product_version'});
|
|
|
|
$test_run->update();
|
|
|
|
$self->logout;
|
|
|
|
# Result is modified test run on success, otherwise an exception will be thrown
|
|
return $test_run;
|
|
}
|
|
|
|
sub get_test_cases
|
|
{
|
|
my $self =shift;
|
|
my ($test_run_id) = @_;
|
|
|
|
$self->login;
|
|
|
|
my $test_run = new Bugzilla::Testopia::TestRun($test_run_id);
|
|
|
|
if (not defined $test_run)
|
|
{
|
|
$self->logout;
|
|
die "Testrun, " . $test_run_id . ", not found";
|
|
}
|
|
|
|
if (not $test_run->canview)
|
|
{
|
|
$self->logout;
|
|
die "User Not Authorized";
|
|
}
|
|
|
|
my $result = $test_run->cases();
|
|
|
|
$self->logout;
|
|
|
|
# Result is list of test cases for the given test run
|
|
return $result;
|
|
}
|
|
|
|
sub get_test_case_runs
|
|
{
|
|
my $self =shift;
|
|
my ($test_run_id) = @_;
|
|
|
|
$self->login;
|
|
|
|
my $test_run = new Bugzilla::Testopia::TestRun($test_run_id);
|
|
|
|
if (not defined $test_run)
|
|
{
|
|
$self->logout;
|
|
die "Testrun, " . $test_run_id . ", not found";
|
|
}
|
|
|
|
if (not $test_run->canview)
|
|
{
|
|
$self->logout;
|
|
die "User Not Authorized";
|
|
}
|
|
|
|
my $result = $test_run->caseruns();
|
|
|
|
$self->logout;
|
|
|
|
# Result is list of test case runs for the given test run
|
|
return $result;
|
|
}
|
|
|
|
sub get_test_plan
|
|
{
|
|
my $self =shift;
|
|
my ($test_run_id) = @_;
|
|
|
|
$self->login;
|
|
|
|
my $test_run = new Bugzilla::Testopia::TestRun($test_run_id);
|
|
|
|
if (not defined $test_run)
|
|
{
|
|
$self->logout;
|
|
die "Testrun, " . $test_run_id . ", not found";
|
|
}
|
|
|
|
if (not $test_run->canview)
|
|
{
|
|
$self->logout;
|
|
die "User Not Authorized";
|
|
}
|
|
|
|
my $result = $test_run->plan();
|
|
|
|
$self->logout;
|
|
|
|
# Result is test plan for the given test run
|
|
return $result;
|
|
}
|
|
|
|
sub lookup_environment_id_by_name
|
|
{
|
|
my $self =shift;
|
|
my ($name) = @_;
|
|
|
|
$self->login;
|
|
|
|
my $result = Bugzilla::Testopia::TestRun::lookup_environment_by_name($name);
|
|
|
|
$self->logout;
|
|
|
|
# Result is test run environment id for the given test run environment name
|
|
return $result;
|
|
}
|
|
|
|
sub lookup_environment_name_by_id
|
|
{
|
|
my $self =shift;
|
|
my ($id) = @_;
|
|
|
|
$self->login;
|
|
|
|
my $test_run = new Bugzilla::Testopia::TestRun({});
|
|
|
|
my $result = $test_run->lookup_environment($id);
|
|
|
|
$self->logout;
|
|
|
|
if (!defined $result)
|
|
{
|
|
$result = 0;
|
|
};
|
|
|
|
# Result is test run environment name for the given test run environment id
|
|
return $result;
|
|
}
|
|
|
|
sub add_tag
|
|
{
|
|
my $self =shift;
|
|
my ($test_run_id, $tag_name) = @_;
|
|
|
|
$self->login;
|
|
|
|
my $test_run = new Bugzilla::Testopia::TestRun($test_run_id);
|
|
|
|
if (not defined $test_run)
|
|
{
|
|
$self->logout;
|
|
die "Testrun, " . $test_run_id . ", not found";
|
|
}
|
|
|
|
if (not $test_run->canedit)
|
|
{
|
|
$self->logout;
|
|
die "User Not Authorized";
|
|
}
|
|
|
|
$test_run->add_tag($tag_name);
|
|
|
|
$self->logout;
|
|
|
|
# Result 0 on success, otherwise an exception will be thrown
|
|
return 0;
|
|
}
|
|
|
|
sub remove_tag
|
|
{
|
|
my $self =shift;
|
|
my ($test_run_id, $tag_name) = @_;
|
|
|
|
$self->login;
|
|
|
|
my $test_run = new Bugzilla::Testopia::TestRun($test_run_id);
|
|
|
|
if (not defined $test_run)
|
|
{
|
|
$self->logout;
|
|
die "Testrun, " . $test_run_id . ", not found";
|
|
}
|
|
|
|
if (not $test_run->canedit)
|
|
{
|
|
$self->logout;
|
|
die "User Not Authorized";
|
|
}
|
|
|
|
my $test_tag = Bugzilla::Testopia::TestTag->check_tag($tag_name);
|
|
if (not defined $test_tag)
|
|
{
|
|
$self->logout;
|
|
die "Tag, " . $tag_name . ", does not exist";
|
|
}
|
|
|
|
my $result = $test_run->remove_tag($test_tag->name);
|
|
|
|
$self->logout;
|
|
|
|
# Result 0 on success, otherwise an exception will be thrown
|
|
return 0;
|
|
}
|
|
|
|
sub get_tags
|
|
{
|
|
my $self =shift;
|
|
my ($test_run_id) = @_;
|
|
|
|
$self->login;
|
|
|
|
my $test_run = new Bugzilla::Testopia::TestRun($test_run_id);
|
|
|
|
if (not defined $test_run)
|
|
{
|
|
$self->logout;
|
|
die "Testrun, " . $test_run_id . ", not found";
|
|
}
|
|
|
|
if (not $test_run->canview)
|
|
{
|
|
$self->logout;
|
|
die "User Not Authorized";
|
|
}
|
|
|
|
my $result = $test_run->tags;
|
|
|
|
$self->logout;
|
|
|
|
# Result list of tags otherwise an exception will be thrown
|
|
return $result;
|
|
}
|
|
|
|
1; |