testasia 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +18 -0
- data/Rakefile +40 -0
- data/VERSION +1 -0
- data/bin/testasia.rb +226 -0
- data/lib/build.rb +35 -0
- data/lib/environment.rb +18 -0
- data/lib/product.rb +31 -0
- data/lib/testcase.rb +205 -0
- data/lib/testplan.rb +113 -0
- data/lib/testrun.rb +196 -0
- metadata +78 -0
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= testasia
|
2
|
+
|
3
|
+
Testasia is a command line client for Testopia[http://www.mozilla.org/projects/testopia/] written in ruby.
|
4
|
+
Currently its functionality is still limited but will be improved over time.
|
5
|
+
|
6
|
+
== Commandline features:
|
7
|
+
- Create Builds
|
8
|
+
- Create Testplans
|
9
|
+
- Create Testcases
|
10
|
+
- Create Testruns
|
11
|
+
|
12
|
+
== Todo
|
13
|
+
|
14
|
+
- Create Environments
|
15
|
+
- Create Testcaseruns (add testcases to runs)
|
16
|
+
- Print Testplan, Testcase, Testrun and Testcaseruns
|
17
|
+
- Delete Testplan, Testcase, Testrun and Testcaseruns
|
18
|
+
- Update Testplan, Testcase, Testrun and Testcaseruns
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
|
4
|
+
desc 'Generate documentation.'
|
5
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
6
|
+
rdoc.rdoc_dir = 'rdoc'
|
7
|
+
rdoc.title = 'active_resource_test_hekper'
|
8
|
+
rdoc.options << '--line-numbers' << "--main" << "README.rdoc"
|
9
|
+
rdoc.rdoc_files.include('README.rdoc')
|
10
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |s|
|
16
|
+
s.name = %q{testasia}
|
17
|
+
s.summary = %q{A commandline client for Testopia (http://www.mozilla.org/projects/testopia/)}
|
18
|
+
s.description = %q{A commandline client for Testopia (http://www.mozilla.org/projects/testopia/)}
|
19
|
+
|
20
|
+
s.files = FileList['[A-Z]*', 'lib/**/*.rb', 'bin/**/*.rb']
|
21
|
+
s.require_path = 'lib'
|
22
|
+
#s.test_files = Dir[*['test/**/*_test.rb']]
|
23
|
+
|
24
|
+
s.has_rdoc = true
|
25
|
+
s.extra_rdoc_files = ["README.rdoc"]
|
26
|
+
s.rdoc_options = ['--line-numbers', "--main", "README.rdoc"]
|
27
|
+
|
28
|
+
s.authors = ["Christian Hueller"]
|
29
|
+
s.email = %q{chuller@suse.de}
|
30
|
+
s.homepage = "http://gitorious.org/testasia"
|
31
|
+
|
32
|
+
s.platform = Gem::Platform::RUBY
|
33
|
+
end
|
34
|
+
Jeweler::GemcutterTasks.new
|
35
|
+
rescue LoadError
|
36
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Clean files generated by rake tasks"
|
40
|
+
task :clobber => [:clobber_rdoc]
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/testasia.rb
ADDED
@@ -0,0 +1,226 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'xmlrpc/client'
|
5
|
+
require 'lib/product.rb'
|
6
|
+
require 'lib/environment.rb'
|
7
|
+
require 'lib/testplan.rb'
|
8
|
+
require 'lib/testcase.rb'
|
9
|
+
require 'lib/testrun.rb'
|
10
|
+
require 'lib/build.rb'
|
11
|
+
|
12
|
+
|
13
|
+
opt = OptionParser.new
|
14
|
+
|
15
|
+
opt.banner = "Usage: #{$0} COMMAND [options]"
|
16
|
+
opt.separator("Commands:")
|
17
|
+
opt.separator(" create_plan\t\t\t Create a new test plan")
|
18
|
+
opt.separator(" create_case\t\t\t Create a new test case")
|
19
|
+
opt.separator(" create_run\t\t\t Create a new test run")
|
20
|
+
opt.separator(" create_caserun\t\t\t Add a testcase to a run")
|
21
|
+
opt.separator(" create_build\t\t\t Add a build to a product")
|
22
|
+
opt.separator(" create_environment\t\t\t Add a environment to a product")
|
23
|
+
opt.separator(" TESTING\t\t\t TEST the script")
|
24
|
+
opt.separator("\n")
|
25
|
+
opt.separator("Generic options:")
|
26
|
+
opt.on( "-a", "--account=", "Testopia/Bugzilla account" ) do |a|
|
27
|
+
$tt_account = a
|
28
|
+
end
|
29
|
+
opt.on( "-w", "--passwd=", "Testopia/Bugzilla password" ) do |w|
|
30
|
+
$tt_password = w
|
31
|
+
end
|
32
|
+
opt.on( "-u", "--uri=", "Testopia/Bugzilla URI" ) do |u|
|
33
|
+
$tt_uri = u
|
34
|
+
end
|
35
|
+
opt.on( "-p", "--product=", "ID or name of the product" ) do |p|
|
36
|
+
$product = p
|
37
|
+
end
|
38
|
+
opt.on( "-n", "--name=", "ID or name of testplan, testrun, build or environment and summary for a testcase" ) do |n|
|
39
|
+
$name = n
|
40
|
+
end
|
41
|
+
opt.on( "-c", "--check=", "if #{$0}=1, do not create anything if it already exists" ) do |c|
|
42
|
+
$check = c
|
43
|
+
end
|
44
|
+
|
45
|
+
opt.separator("\nOptions required for \"create_plan\":")
|
46
|
+
opt.on( "-t", "--type=", "type of testplan" ) do |t|
|
47
|
+
$type = t
|
48
|
+
end
|
49
|
+
opt.on( "-d", "--default_product_version=", "The product version of the testplan" ) do |d|
|
50
|
+
$default_product_version = d
|
51
|
+
end
|
52
|
+
|
53
|
+
opt.separator("\nOptions required for \"create_case\":")
|
54
|
+
opt.on( "-s", "--status=", "status of the testcase" ) do |s|
|
55
|
+
$status = s
|
56
|
+
end
|
57
|
+
opt.on( "-o", "--category=", "Category of the testcase" ) do |c|
|
58
|
+
$category = c
|
59
|
+
end
|
60
|
+
opt.on( "-y", "--priority=", "Priority of the testcase" ) do |y|
|
61
|
+
$priority = y
|
62
|
+
end
|
63
|
+
opt.on( "-l", "--plan=", "plan the testcase gets added" ) do |l|
|
64
|
+
$plans = l
|
65
|
+
end
|
66
|
+
|
67
|
+
opt.separator("\nOptions required for \"create_run\":")
|
68
|
+
opt.on( "-x", "--plan-id=", "Plan ID the testrun gets added" ) do |l|
|
69
|
+
$plan_id = l
|
70
|
+
end
|
71
|
+
opt.on( "-e", "--environment=", "Environment for the testrun" ) do |e|
|
72
|
+
$environment = e
|
73
|
+
end
|
74
|
+
opt.on( "-b", "--build=", "Build for the testrun" ) do |b|
|
75
|
+
$build = b
|
76
|
+
end
|
77
|
+
opt.on( "-m", "--manager=", "Manager of the testrun" ) do |m|
|
78
|
+
$manager = m
|
79
|
+
end
|
80
|
+
|
81
|
+
opt.separator("\nOptions required for \"create_caseruni\":")
|
82
|
+
opt.on( "-r", "--run_id=", "id of the testrun testcases get added" ) do |r|
|
83
|
+
$run_id = r
|
84
|
+
end
|
85
|
+
opt.on( "-i", "--case_id=", "id of the testcase to added" ) do |i|
|
86
|
+
$case_id = i
|
87
|
+
end
|
88
|
+
opt.on( "-b", "--build=", "build for the testcaserun" ) do |b|
|
89
|
+
$build = b
|
90
|
+
end
|
91
|
+
opt.on( "-e", "--environment=", "environment for the testrun" ) do |e|
|
92
|
+
$environment = e
|
93
|
+
end
|
94
|
+
|
95
|
+
opt.on( "-h", "--help", "Print this message" ) do
|
96
|
+
puts opt
|
97
|
+
exit
|
98
|
+
end
|
99
|
+
|
100
|
+
begin
|
101
|
+
opt.parse!( ARGV )
|
102
|
+
rescue OptionParser::InvalidOption
|
103
|
+
STDERR.puts $!
|
104
|
+
STDERR.puts opt
|
105
|
+
exit 1
|
106
|
+
end
|
107
|
+
|
108
|
+
mode = ARGV[0]
|
109
|
+
if mode.nil? or !["TESTING", "create_plan", "create_case", "create_run", "create_caserun", "create_build", "create_environment"].include?(mode)
|
110
|
+
STDERR.puts opt
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
# evaluate some options and adjust accordingly
|
115
|
+
#
|
116
|
+
$summary = $name
|
117
|
+
if $check == "0"
|
118
|
+
$check = false
|
119
|
+
else
|
120
|
+
$check = true
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
# array containing required argumnets per mode
|
125
|
+
#
|
126
|
+
mode_args = {"create_plan"=>{"product"=>$product, "name"=>$name, "type"=>$type, "default_product_version"=>$default_product_version},
|
127
|
+
"create_case"=>{"status"=>$status, "category"=>$category, "priority"=>$priority, "summary"=>$summary, "plans"=>$plans},
|
128
|
+
"create_run"=>{"plan_id"=>$plan_id, "environment"=>$environment, "build"=>$build, "manager"=>$manager, "summary"=>$summary},
|
129
|
+
"create_caserun"=>{"run_id"=>$run_id, "case_id"=>$case_id, "build"=>$build, "environment"=>$environment},
|
130
|
+
"create_build"=>{"product"=>$product, "name"=>$name},
|
131
|
+
"create_environment"=>{"product_id"=>$product_id, "name"=>$name}}
|
132
|
+
$content = mode_args[mode]
|
133
|
+
|
134
|
+
|
135
|
+
# locally used subroutines
|
136
|
+
#
|
137
|
+
|
138
|
+
def check_options(mode, content)
|
139
|
+
missing = Array.new
|
140
|
+
content.each do |key, value|
|
141
|
+
if value.nil?
|
142
|
+
missing = missing.push(key)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
if !missing.empty?
|
146
|
+
missing = missing * "\n"
|
147
|
+
print "For the mode \"", mode, "\" these options have to be set:\n", missing, "\n"
|
148
|
+
exit 1
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
def tt_login(account, password, uri)
|
154
|
+
uri =~ /(.*)(\/.*)/
|
155
|
+
host = $1
|
156
|
+
path = $2
|
157
|
+
|
158
|
+
puts "Logging into testopia"
|
159
|
+
$server = XMLRPC::Client.new(host, path, nil, nil, nil, account, password, true)
|
160
|
+
puts "Testopia version:"
|
161
|
+
puts $server.call("Testopia.testopia_version")
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
# "main"
|
166
|
+
#
|
167
|
+
|
168
|
+
check_options(mode, $content)
|
169
|
+
tt_login($tt_account, $tt_password, $tt_uri)
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
if mode == "create_build"
|
174
|
+
puts "Creating Build"
|
175
|
+
b = Build.new
|
176
|
+
b.build = $content
|
177
|
+
b.check_build = $check
|
178
|
+
build = b.create
|
179
|
+
puts build.inspect
|
180
|
+
|
181
|
+
|
182
|
+
elsif mode == "create_environment"
|
183
|
+
puts "Creating Environment"
|
184
|
+
puts " Yet to be implemented "
|
185
|
+
|
186
|
+
|
187
|
+
elsif mode == "create_caserun"
|
188
|
+
puts "Create CaseRun"
|
189
|
+
puts " Yet to be implemented "
|
190
|
+
|
191
|
+
|
192
|
+
elsif mode == "create_plan"
|
193
|
+
puts "Create Testplan"
|
194
|
+
tp = Testplan.new($content)
|
195
|
+
tp.check = $check
|
196
|
+
testplan = tp.write
|
197
|
+
puts testplan.inspect
|
198
|
+
|
199
|
+
|
200
|
+
elsif mode == "create_case"
|
201
|
+
puts "Create Testcase"
|
202
|
+
tc = Testcase.new($content)
|
203
|
+
tc.check = $check
|
204
|
+
testcase = tc.write
|
205
|
+
puts testplan
|
206
|
+
|
207
|
+
|
208
|
+
elsif mode == "create_run"
|
209
|
+
puts "Create Testrun"
|
210
|
+
tr = Testrun.new($content)
|
211
|
+
tr.check = $check
|
212
|
+
testrun = tr.write
|
213
|
+
puts testrun
|
214
|
+
|
215
|
+
|
216
|
+
elsif mode == "TESTING"
|
217
|
+
puts "RUNNING TESTS"
|
218
|
+
|
219
|
+
dada = Testcase.new
|
220
|
+
dada.testcase = {"summary"=>"kdesd", "plan_id"=>2943}
|
221
|
+
if dada.exists?
|
222
|
+
puts true
|
223
|
+
else
|
224
|
+
puts false
|
225
|
+
end
|
226
|
+
end
|
data/lib/build.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
class Build
|
2
|
+
def initialize(build=nil)
|
3
|
+
@build = build
|
4
|
+
@check_build = false
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_reader :build, :check_build
|
8
|
+
attr_writer :build, :check_build
|
9
|
+
|
10
|
+
def check
|
11
|
+
puts "checking if build already exists"
|
12
|
+
begin
|
13
|
+
@build = $server.call("Build.check_build", @build["name"], @build["product"])
|
14
|
+
rescue
|
15
|
+
return @build
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
if @build["name"].nil?
|
21
|
+
puts "Build name not set"
|
22
|
+
return false
|
23
|
+
elsif @build["product"].nil?
|
24
|
+
puts "Build product not set"
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
puts @check_build
|
28
|
+
if @check_build == true
|
29
|
+
self.check
|
30
|
+
end
|
31
|
+
@build = $server.call("Build.create", @build)
|
32
|
+
return @build
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
data/lib/environment.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class Environment
|
2
|
+
def initialize(environment=nil)
|
3
|
+
@environment = environment
|
4
|
+
end
|
5
|
+
|
6
|
+
attr_writer :environment
|
7
|
+
attr_reader :environment
|
8
|
+
|
9
|
+
def get_id
|
10
|
+
@environments = $server.call("Environment.list", environment)
|
11
|
+
#As testopia returns anything with the environment string in it we need to match exactly
|
12
|
+
@environments.each do |i|
|
13
|
+
if i.has_value?(environment_name)
|
14
|
+
return i["environment_id"]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/product.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
class Product
|
2
|
+
def initialize(product)
|
3
|
+
@product = product
|
4
|
+
end
|
5
|
+
|
6
|
+
|
7
|
+
def get_builds(active)
|
8
|
+
@builds = $server.call("Product.get_builds", @product, active)
|
9
|
+
return @builds
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def get_environments
|
14
|
+
@environments = $server.call("Product.get_environments", @product)
|
15
|
+
return @environments
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def get_categories
|
20
|
+
@categories = $server.call("Product.get_categories", @product)
|
21
|
+
return @categories
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def get_components
|
26
|
+
@components = $server.call("Product.get_components", @product)
|
27
|
+
return @product
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
data/lib/testcase.rb
ADDED
@@ -0,0 +1,205 @@
|
|
1
|
+
# testcase hash layout:
|
2
|
+
#
|
3
|
+
# +-------------------+----------------+-----------+------------------------+
|
4
|
+
# | Field | Type | Null | Description |
|
5
|
+
# +-------------------+----------------+-----------+------------------------+
|
6
|
+
# | status | Integer/String | Required | ID or Name of status |
|
7
|
+
# | category* | Integer/Hash | Required | ID or hash |
|
8
|
+
# | priority | Integer/String | Required | ID or Name of Priority |
|
9
|
+
# | summary | String | Required | |
|
10
|
+
# | plans | Array/Str/Int | Required | ID or List of plan_ids |
|
11
|
+
# | default_tester | Integer/String | Optional | ID or Login of tester |
|
12
|
+
# | estimated_time | String | Optional | HH:MM:SS Format |
|
13
|
+
# | isautomated | Boolean | Optional | Defaults to False (0) |
|
14
|
+
# | sortkey | Integer | Optional | |
|
15
|
+
# | script | String | Optional | |
|
16
|
+
# | arguments | String | Optional | |
|
17
|
+
# | requirement | String | Optional | |
|
18
|
+
# | alias | String | Optional | Must be unique |
|
19
|
+
# | action | String | Optional | |
|
20
|
+
# | effect | String | Optional | ExpectedResult |
|
21
|
+
# | setup | String | Optional | |
|
22
|
+
# | breakdown | String | Optional | |
|
23
|
+
# | dependson | Array/String | Optional | String Comma separated |
|
24
|
+
# | blocks | Array/String | Optional | String Comma separated |
|
25
|
+
# | tags | Array/String | Optional | String Comma separated |
|
26
|
+
# | bugs | Array/String | Optional | String Comma separated |
|
27
|
+
# | components+ | Array/Hash/Str | Optional | String Comma separated |
|
28
|
+
# +-------------------+----------------+-----------+------------------------+
|
29
|
+
# * category hash = {category => 'string', product => 'string'}
|
30
|
+
# + components can be an array of IDs, a comma separated string of IDs,
|
31
|
+
# an array of Hashes, or a single hash.
|
32
|
+
# component hash = {component => 'string', product => 'string'}
|
33
|
+
# +--------------------------------------------------------+
|
34
|
+
# | Case Search Parameters |
|
35
|
+
# +--------------------------------------------------------+
|
36
|
+
# | Key | Valid Values |
|
37
|
+
# | andor | 1: Author AND tester, 0: OR |
|
38
|
+
# | author | A bugzilla login (email address) |
|
39
|
+
# | author_type | (select from email_variants) |
|
40
|
+
# | case_id | comma separated integers |
|
41
|
+
# | case_status | String: Status |
|
42
|
+
# | case_status_id | Integer: Status |
|
43
|
+
# | category | String: Category Name |
|
44
|
+
# | category_id | Integer |
|
45
|
+
# | component | String: Component Name |
|
46
|
+
# | default_tester | A bugzilla login (email address) |
|
47
|
+
# | default_tester_type | (select from email_variants) |
|
48
|
+
# | isautomated | 1: true 0: false |
|
49
|
+
# | plan_id | comma separated integers |
|
50
|
+
# | priority | String: Priority |
|
51
|
+
# | priority_id | Integer |
|
52
|
+
# | product | String: Product Name |
|
53
|
+
# | product_id | Integer |
|
54
|
+
# | requirement | String: Requirement |
|
55
|
+
# | requirement_type | (select from query_variants) |
|
56
|
+
# | run_id | comma separated integers |
|
57
|
+
# | script | String |
|
58
|
+
# | script_type | (select from query_variants) |
|
59
|
+
# | summary | String |
|
60
|
+
# | summary_type | (select from query_variants) |
|
61
|
+
# | tags | String |
|
62
|
+
# | tags_type | (select from tag_variants) |
|
63
|
+
# | tcaction | String |
|
64
|
+
# | tcaction_type | (select from query_variants) |
|
65
|
+
# | tceffect | String |
|
66
|
+
# | tceffect_type | (select from query_variants) |
|
67
|
+
# +--------------------------------------------------------+
|
68
|
+
#
|
69
|
+
# +---------------------------------------------------+
|
70
|
+
# | Paging and Sorting |
|
71
|
+
# +---------------------------------------------------+
|
72
|
+
# | Key | Description |
|
73
|
+
# | dir | "ASC" or "DESC" |
|
74
|
+
# | order | field to sort by |
|
75
|
+
# +---------------------------------------------------+
|
76
|
+
# | page_size | integer: how many per page |
|
77
|
+
# | page | integer: page number |
|
78
|
+
# | +++++++ OR +++++++ |
|
79
|
+
# | start | integer: Start with which record |
|
80
|
+
# | limit | integer: limit to how many |
|
81
|
+
# +---------------------------------------------------+
|
82
|
+
# | viewall | 1: returns all records |
|
83
|
+
# +---------------------------------------------------+
|
84
|
+
# * The default is to only return 25 records at a time
|
85
|
+
#
|
86
|
+
# +----------------------------------------------------+
|
87
|
+
# | query_variants |
|
88
|
+
# +----------------+-----------------------------------+
|
89
|
+
# | Key | Description |
|
90
|
+
# | allwordssubstr | contains all of the words/strings |
|
91
|
+
# | anywordssubstr | contains any of the words/strings |
|
92
|
+
# | substring | contains the string |
|
93
|
+
# | casesubstring | contains the string (exact case) |
|
94
|
+
# | allwords | contains all of the words |
|
95
|
+
# | anywords | contains any of the words |
|
96
|
+
# | regexp | matches the regexp |
|
97
|
+
# | notregexp | doesn't match the regexp |
|
98
|
+
# +----------------+-----------------------------------+
|
99
|
+
#
|
100
|
+
# +-------------------------------------+
|
101
|
+
# | email_variants |
|
102
|
+
# +--------------+----------------------+
|
103
|
+
# | Key | Description |
|
104
|
+
# | substring | contains |
|
105
|
+
# | exact | is |
|
106
|
+
# | regexp | matches regexp |
|
107
|
+
# | notregexp | doesn't match regexp |
|
108
|
+
# +--------------+----------------------+
|
109
|
+
#
|
110
|
+
# +----------------------------------------------------+
|
111
|
+
# | tag_variants |
|
112
|
+
# +----------------+-----------------------------------+
|
113
|
+
# | Key | Description |
|
114
|
+
# | anyexact | is tagged with |
|
115
|
+
# | allwordssubstr | contains all of the words/strings |
|
116
|
+
# | anywordssubstr | contains any of the words/strings |
|
117
|
+
# | substring | contains the string |
|
118
|
+
# | casesubstring | contains the string (exact case) |
|
119
|
+
# | regexp | matches the regexp |
|
120
|
+
# | notregexp | doesn't match the regexp |
|
121
|
+
# | allwords | contains all of the words |
|
122
|
+
# | anywords | contains any of the words |
|
123
|
+
# | nowords | contains none of the words |
|
124
|
+
# +----------------------------------------------------+
|
125
|
+
#
|
126
|
+
|
127
|
+
|
128
|
+
class Testcase
|
129
|
+
def initialize(testcase=nil)
|
130
|
+
@testcase = testcase
|
131
|
+
@check = true
|
132
|
+
end
|
133
|
+
|
134
|
+
attr_reader :testcase, :check
|
135
|
+
attr_writer :testcase, :check
|
136
|
+
|
137
|
+
def write
|
138
|
+
if @testcase["summary"].nil?
|
139
|
+
puts "Testcase summary needs to have some value"
|
140
|
+
return false
|
141
|
+
elsif @testcase["category"].nil?
|
142
|
+
puts "Testcase category must be set"
|
143
|
+
return false
|
144
|
+
elsif @testcase["plans"].nil?
|
145
|
+
puts "No testplans defined to add testcase"
|
146
|
+
return false
|
147
|
+
end
|
148
|
+
if @testcase["priority"].nil?
|
149
|
+
puts "Testcase priority not set. Using [P5 - None]"
|
150
|
+
@testcase["priority"] = "P5 - None"
|
151
|
+
end
|
152
|
+
if @testcase["status"].nil?
|
153
|
+
puts "Testcase status not set. Using [PROPOSED]"
|
154
|
+
@testcase["status"] = "PROPOSED"
|
155
|
+
end
|
156
|
+
|
157
|
+
if @check
|
158
|
+
if self.exists?
|
159
|
+
puts "Testcase already existing - aborting"
|
160
|
+
return false
|
161
|
+
else
|
162
|
+
@testcase = $server.call("TestCase.create", @testcase)
|
163
|
+
return @testcase
|
164
|
+
end
|
165
|
+
else
|
166
|
+
@testcase = $server.call("TestCase.create", @testcase)
|
167
|
+
return @testcase
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
def read(id)
|
173
|
+
@testcase = $server.call("TestCase.get", id)
|
174
|
+
return @testcase
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
def print
|
179
|
+
puts @testcase.inspect
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
def find
|
184
|
+
puts @testcase.inspect
|
185
|
+
@result = $server.call("TestCase.list", @testcase)
|
186
|
+
return @result
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
def exists?
|
191
|
+
@result = self.find
|
192
|
+
if @result.empty?
|
193
|
+
return false
|
194
|
+
else
|
195
|
+
return true
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
def get_plans(case_id)
|
201
|
+
@result = $server.call("TestCase.list", case_id)
|
202
|
+
return @result
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
data/lib/testplan.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# testplan hash layout
|
2
|
+
#
|
3
|
+
# +-------------------------+----------------+-----------+------------------------------------+
|
4
|
+
# | Field | Type | Null | Description |
|
5
|
+
# +-------------------------+----------------+-----------+------------------------------------+
|
6
|
+
# | product | Integer/String | Required | ID or Name of product |
|
7
|
+
# | name | String | Required | |
|
8
|
+
# | type | Integer/String | Required | ID or name of plan type |
|
9
|
+
# | default_product_version | String | Required | |
|
10
|
+
# | isactive | Boolean | Optional | 0: Archived 1: Active (Default 1) |
|
11
|
+
# +-------------------------+----------------+-----------+------------------------------------+
|
12
|
+
#
|
13
|
+
#
|
14
|
+
# +--------------------------------------------------------+
|
15
|
+
# | Plan Search Parameters |
|
16
|
+
# +--------------------------------------------------------+
|
17
|
+
# | Key | Valid Values |
|
18
|
+
# | author | A bugzilla login (email address) |
|
19
|
+
# | author_type | (select from email_variants) |
|
20
|
+
# | plan_id | comma separated integers |
|
21
|
+
# | plan_text | String |
|
22
|
+
# | plan_text_type | (select from query_variants) |
|
23
|
+
# | plan_type | String: Product Name |
|
24
|
+
# | product | String: Product Name |
|
25
|
+
# | product_id | Integer |
|
26
|
+
# | tags | String |
|
27
|
+
# | tags_type | (select from tag_variants) |
|
28
|
+
# | type_id | Integer |
|
29
|
+
# | version | String: Product version |
|
30
|
+
# +--------------------------------------------------------+
|
31
|
+
#
|
32
|
+
|
33
|
+
|
34
|
+
class Testplan
|
35
|
+
def initialize(testplan=nil)
|
36
|
+
@testplan = testplan
|
37
|
+
@check = true
|
38
|
+
end
|
39
|
+
|
40
|
+
attr_reader :testplan, :check
|
41
|
+
attr_writer :testplan, :check
|
42
|
+
|
43
|
+
|
44
|
+
def write
|
45
|
+
if @testplan["product"].nil?
|
46
|
+
puts "No product ID set while attempting to create Testplan"
|
47
|
+
return false
|
48
|
+
elsif @testplan["name"].nil?
|
49
|
+
puts "No name is set while attempting to create a testplan"
|
50
|
+
return false
|
51
|
+
elsif @testplan["default_product_version"].nil?
|
52
|
+
puts "No product_version is set while attempting to create a testplan"
|
53
|
+
return false
|
54
|
+
end
|
55
|
+
|
56
|
+
if @testplan["isactive"].nil?
|
57
|
+
puts "Activity state of testplan not set while creating testplan. Using [isactive = 1]"
|
58
|
+
@testplan["isactive"] = 1
|
59
|
+
end
|
60
|
+
if @testplan["type"].nil?
|
61
|
+
puts "Testplan type not set while creating Testplan. Using [Function]"
|
62
|
+
@testplan["type"] = "Function"
|
63
|
+
end
|
64
|
+
|
65
|
+
if @check
|
66
|
+
if self.exists?
|
67
|
+
puts "Testplan already existing - aborting"
|
68
|
+
return false
|
69
|
+
else
|
70
|
+
@testplan = $server.call("TestPlan.create", @testplan)
|
71
|
+
return @testplan
|
72
|
+
end
|
73
|
+
else
|
74
|
+
@testplan = $server.call("TestPlan.create", @testplan)
|
75
|
+
return @testplan
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
def read(id)
|
81
|
+
@testplan = $server.call("TestPlan.get", id)
|
82
|
+
return @testplan
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def print
|
87
|
+
puts @testplan.inspect
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def find
|
92
|
+
@query = {"name"=>@testplan["name"], "product_id"=>@testplan["product"]}
|
93
|
+
@result = $server.call("TestPlan.list", @query)
|
94
|
+
return @result
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def exists?
|
99
|
+
@result = self.find
|
100
|
+
if @result.empty?
|
101
|
+
return false
|
102
|
+
else
|
103
|
+
return true
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
def get_product_id(plan_id)
|
109
|
+
@product = $server.call("TestPlan.get_product", plan_id)
|
110
|
+
return @product["id"]
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
data/lib/testrun.rb
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
# testrun hash layout
|
2
|
+
#
|
3
|
+
# matching the fields of the test run to be created.
|
4
|
+
# +-------------------+----------------+-----------+------------------------------------+
|
5
|
+
# | Field | Type | Null | Description |
|
6
|
+
# +-------------------+----------------+-----------+------------------------------------+
|
7
|
+
# | plan_id | Integer | Required | ID of test plan |
|
8
|
+
# | environment | Integer/String | Required | ID or Name of Environment |
|
9
|
+
# | build | Integer/String | Required | ID or Name of Build |
|
10
|
+
# | manager | Integer/String | Required | ID or Login of run manager |
|
11
|
+
# | summary | String | Required | |
|
12
|
+
# | product_version | String | Optional | Defaults to plan's version |
|
13
|
+
# | plan_text_version | Integer | Optional | |
|
14
|
+
# | target_completion | Integer | Optional | Targetted Completion percentage |
|
15
|
+
# | target_pass | Integer | Optional | Targetted Pass percentage |
|
16
|
+
# | notes | String | Optional | |
|
17
|
+
# | status | Integer | Optional | 0:STOPPED 1: RUNNING (default 1) |
|
18
|
+
# | cases | Array/String | Optional | list of case ids to add to the run |
|
19
|
+
# +-------------------+----------------+-----------+------------------------------------+
|
20
|
+
#
|
21
|
+
#
|
22
|
+
# +--------------------------------------------------------+
|
23
|
+
# | Run Search Parameters |
|
24
|
+
# +--------------------------------------------------------+
|
25
|
+
# | Key | Valid Values |
|
26
|
+
# | build | String: Product Name |
|
27
|
+
# | build_id | Integer |
|
28
|
+
# | environment | String: Product Name |
|
29
|
+
# | environment_id | Integer |
|
30
|
+
# | manager | A bugzilla login (email address) |
|
31
|
+
# | manager_type | (select from email_variants) |
|
32
|
+
# | milestone | String |
|
33
|
+
# | notes | String |
|
34
|
+
# | notes_type | (select from query_variants) |
|
35
|
+
# | plan_id | comma separated integers |
|
36
|
+
# | product | String: Product Name |
|
37
|
+
# | product_id | Integer |
|
38
|
+
# | run_id | comma separated integers |
|
39
|
+
# | run_status | 1: RUNNING 0: STOPPED |
|
40
|
+
# | summary | String |
|
41
|
+
# | summary_type | (select from query_variants) |
|
42
|
+
# | tags | String |
|
43
|
+
# | tags_type | (select from tag_variants) |
|
44
|
+
# | type_id | Integer |
|
45
|
+
# | version | String: Product version |
|
46
|
+
# +--------------------------------------------------------+
|
47
|
+
#
|
48
|
+
# +--------------------------------------------------------+
|
49
|
+
# | Paging and Sorting |
|
50
|
+
# +--------------------------------------------------------+
|
51
|
+
# | Key | Description |
|
52
|
+
# | dir | "ASC" or "DESC" |
|
53
|
+
# | order | field to sort by |
|
54
|
+
# +--------------------------------------------------------+
|
55
|
+
# | page_size | integer: how many per page |
|
56
|
+
# | page | integer: page number |
|
57
|
+
# | +++++++ OR +++++++ |
|
58
|
+
# | start | integer: Start with which record |
|
59
|
+
# | limit | integer: limit to how many |
|
60
|
+
# +--------------------------------------------------------+
|
61
|
+
# | viewall | 1: returns all records 0: first 25 |
|
62
|
+
# +--------------------------------------------------------+
|
63
|
+
# * The default is to only return 25 records at a time
|
64
|
+
#
|
65
|
+
# +----------------------------------------------------+
|
66
|
+
# | query_variants |
|
67
|
+
# +----------------+-----------------------------------+
|
68
|
+
# | Key | Description |
|
69
|
+
# | allwordssubstr | contains all of the words/strings |
|
70
|
+
# | anywordssubstr | contains any of the words/strings |
|
71
|
+
# | substring | contains the string |
|
72
|
+
# | casesubstring | contains the string (exact case) |
|
73
|
+
# | allwords | contains all of the words |
|
74
|
+
# | anywords | contains any of the words |
|
75
|
+
# | regexp | matches the regexp |
|
76
|
+
# | notregexp | doesn't match the regexp |
|
77
|
+
# +----------------+-----------------------------------+
|
78
|
+
#
|
79
|
+
# +-------------------------------------+
|
80
|
+
# | email_variants |
|
81
|
+
# +--------------+----------------------+
|
82
|
+
# | Key | Description |
|
83
|
+
# | substring | contains |
|
84
|
+
# | exact | is |
|
85
|
+
# | regexp | matches regexp |
|
86
|
+
# | notregexp | doesn't match regexp |
|
87
|
+
# +--------------+----------------------+
|
88
|
+
#
|
89
|
+
# +----------------------------------------------------+
|
90
|
+
# | tag_variants |
|
91
|
+
# +----------------+-----------------------------------+
|
92
|
+
# | Key | Description |
|
93
|
+
# | anyexact | is tagged with |
|
94
|
+
# | allwordssubstr | contains all of the words/strings |
|
95
|
+
# | anywordssubstr | contains any of the words/strings |
|
96
|
+
# | substring | contains the string |
|
97
|
+
# | casesubstring | contains the string (exact case) |
|
98
|
+
# | regexp | matches the regexp |
|
99
|
+
# | notregexp | doesn't match the regexp |
|
100
|
+
# | allwords | contains all of the words |
|
101
|
+
# | anywords | contains any of the words |
|
102
|
+
# | nowords | contains none of the words |
|
103
|
+
# +----------------------------------------------------+
|
104
|
+
#
|
105
|
+
#
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
class Testrun
|
110
|
+
def initialize(testrun=nil)
|
111
|
+
@testrun = testrun
|
112
|
+
@check = true
|
113
|
+
end
|
114
|
+
|
115
|
+
attr_reader :testrun, :check
|
116
|
+
attr_writer :testrun, :check
|
117
|
+
|
118
|
+
def write
|
119
|
+
if @testrun["plan_id"].nil?
|
120
|
+
puts "Testrun plan_id not set"
|
121
|
+
return false
|
122
|
+
elsif @testrun["environment"].nil?
|
123
|
+
puts "Testrun environment not set"
|
124
|
+
return false
|
125
|
+
elsif @testrun["build"].nil?
|
126
|
+
puts "Testrun build not set"
|
127
|
+
return false
|
128
|
+
elsif @testrun["summary"].nil?
|
129
|
+
puts "Testrun summary not set"
|
130
|
+
return false
|
131
|
+
end
|
132
|
+
if @testrun["manager"].nil?
|
133
|
+
puts "Testrun manager not set. Using ",$tt_account," as manager"
|
134
|
+
@testrun["manager"] = $tt_account
|
135
|
+
end
|
136
|
+
|
137
|
+
if @check
|
138
|
+
if self.exists?
|
139
|
+
puts "Testrun already existing - aborting"
|
140
|
+
return false
|
141
|
+
else
|
142
|
+
@testrun = $server.call("TestRun.create", @testrun)
|
143
|
+
return @testrun
|
144
|
+
end
|
145
|
+
end
|
146
|
+
@testrun = $server.call("TestRun.create", @testrun)
|
147
|
+
return @testrun
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
def read(id)
|
152
|
+
@testrun = $server.call("TestRun.get", id)
|
153
|
+
return @testrun
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
def print
|
158
|
+
puts @tr
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
def find
|
163
|
+
puts @testcase.inspect
|
164
|
+
@result = $server.call("TestRun.list", @testrun)
|
165
|
+
return @result
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
def exists?
|
170
|
+
@result = self.find
|
171
|
+
if @result.empty?
|
172
|
+
return false
|
173
|
+
else
|
174
|
+
return true
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
def add(case_ids)
|
180
|
+
@case_ids = case_ids
|
181
|
+
|
182
|
+
if @testrun["run_id"].nil
|
183
|
+
puts "No test run_id set"
|
184
|
+
return false
|
185
|
+
else
|
186
|
+
@result = $server.call("TestRun.add_cases", @case_ids, @testrun["run_id"])
|
187
|
+
if @result.empty?
|
188
|
+
return true
|
189
|
+
else
|
190
|
+
return false
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: testasia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Christian Hueller
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-15 00:00:00 +02:00
|
19
|
+
default_executable: testasia.rb
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: A commandline client for Testopia (http://www.mozilla.org/projects/testopia/)
|
23
|
+
email: chuller@suse.de
|
24
|
+
executables:
|
25
|
+
- testasia.rb
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- README.rdoc
|
32
|
+
- Rakefile
|
33
|
+
- VERSION
|
34
|
+
- bin/testasia.rb
|
35
|
+
- lib/build.rb
|
36
|
+
- lib/environment.rb
|
37
|
+
- lib/product.rb
|
38
|
+
- lib/testcase.rb
|
39
|
+
- lib/testplan.rb
|
40
|
+
- lib/testrun.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://gitorious.org/testasia
|
43
|
+
licenses: []
|
44
|
+
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --line-numbers
|
48
|
+
- --main
|
49
|
+
- README.rdoc
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.3.7
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: A commandline client for Testopia (http://www.mozilla.org/projects/testopia/)
|
77
|
+
test_files: []
|
78
|
+
|