testdroid-api-client 0.2.3 → 0.3.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.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/Gemfile.lock +48 -22
- data/lib/testdroid-api-client.rb +22 -6
- data/lib/testdroid-api-filter-builder.rb +145 -0
- data/lib/testdroid_api/admin.rb +25 -0
- data/lib/testdroid_api/admin_device_models.rb +10 -0
- data/lib/testdroid_api/admin_device_problems.rb +9 -0
- data/lib/testdroid_api/admin_device_statuses.rb +12 -0
- data/lib/testdroid_api/admin_devices.rb +10 -0
- data/lib/testdroid_api/apikey_client.rb +120 -0
- data/lib/testdroid_api/client.rb +166 -123
- data/lib/testdroid_api/cloud_list_resource.rb +73 -70
- data/lib/testdroid_api/cloud_resource.rb +83 -71
- data/lib/testdroid_api/config.rb +7 -7
- data/lib/testdroid_api/device_groups.rb +8 -9
- data/lib/testdroid_api/device_runs.rb +4 -2
- data/lib/testdroid_api/device_session_connections.rb +10 -0
- data/lib/testdroid_api/device_sessions.rb +12 -12
- data/lib/testdroid_api/devices.rb +8 -11
- data/lib/testdroid_api/file_sets.rb +8 -9
- data/lib/testdroid_api/files.rb +57 -58
- data/lib/testdroid_api/label_groups.rb +9 -10
- data/lib/testdroid_api/labels.rb +9 -10
- data/lib/testdroid_api/parameters.rb +7 -8
- data/lib/testdroid_api/projects.rb +13 -15
- data/lib/testdroid_api/properties.rb +13 -0
- data/lib/testdroid_api/runs.rb +13 -12
- data/lib/testdroid_api/services.rb +18 -0
- data/lib/testdroid_api/user.rb +6 -6
- data/sample/sample.rb +16 -11
- data/testdroid-api-client.gemspec +4 -2
- metadata +53 -3
data/lib/testdroid_api/config.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module TestdroidAPI
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
class Config < CloudResource
|
3
|
+
def initialize(uri, client, params={})
|
4
|
+
super uri, client, "config", params
|
5
|
+
@uri, @client = uri, client
|
6
|
+
sub_items :parameters
|
7
|
+
end
|
8
|
+
end
|
9
9
|
end
|
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
1
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
class DeviceGroups < CloudListResource
|
3
|
+
end
|
4
|
+
class DeviceGroup < CloudResource
|
5
|
+
def initialize(uri, client, params= {})
|
6
|
+
super uri, client, "deviceGroup", params
|
7
|
+
@uri, @client = uri, client
|
8
|
+
end
|
10
9
|
|
11
|
-
|
10
|
+
end
|
12
11
|
end
|
@@ -1,18 +1,20 @@
|
|
1
|
-
|
2
1
|
module TestdroidAPI
|
3
2
|
class DeviceRuns < CloudListResource
|
4
3
|
end
|
5
4
|
class DeviceRun < CloudResource
|
6
5
|
def initialize(uri, client, params= {})
|
7
|
-
super uri, client,"deviceRun", params
|
6
|
+
super uri, client, "deviceRun", params
|
8
7
|
@uri, @client = uri, client
|
9
8
|
end
|
9
|
+
|
10
10
|
def download_performance(file_name="performance_data.txt")
|
11
11
|
@client.download("#{@uri}/performance", file_name)
|
12
12
|
end
|
13
|
+
|
13
14
|
def download_junit(file_name="junit.xml")
|
14
15
|
@client.download("#{@uri}/junit.xml", file_name)
|
15
16
|
end
|
17
|
+
|
16
18
|
def download_logs(file_name="log.txt")
|
17
19
|
@client.download("#{@uri}/logs", file_name)
|
18
20
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module TestdroidAPI
|
2
|
+
class DeviceSessionConnections < CloudListResource
|
3
|
+
end
|
4
|
+
class DeviceSessionConnection < CloudResource
|
5
|
+
def initialize(uri, client, params= {})
|
6
|
+
super uri, client, "DeviceSessionConnection", params
|
7
|
+
@uri, @client = uri, client
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
|
2
1
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
2
|
+
class DeviceSessions < CloudListResource
|
3
|
+
end
|
4
|
+
class DeviceSession < CloudResource
|
5
|
+
def initialize(uri, client, params= {})
|
6
|
+
super uri, client, "deviceSession", params
|
7
|
+
@uri, @client = uri, client
|
8
|
+
end
|
9
|
+
|
10
|
+
def release
|
11
|
+
resp = @client.post("#{@uri}/release", params= {})
|
12
|
+
end
|
13
|
+
end
|
14
14
|
end
|
@@ -1,13 +1,10 @@
|
|
1
|
-
|
2
1
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
2
|
+
class Devices < CloudListResource
|
3
|
+
end
|
4
|
+
class Device < CloudResource
|
5
|
+
def initialize(uri, client, params= {})
|
6
|
+
super uri, client, "device", params
|
7
|
+
@uri, @client = uri, client
|
8
|
+
end
|
9
|
+
end
|
13
10
|
end
|
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
1
|
module TestdroidAPI
|
3
|
-
|
2
|
+
class FileSets < CloudListResource
|
3
|
+
end
|
4
|
+
class FileSet < CloudResource
|
5
|
+
def initialize(uri, client, params= {})
|
6
|
+
super uri, client, "fileSet", params
|
7
|
+
@uri, @client = uri, client
|
8
|
+
sub_items :files
|
4
9
|
end
|
5
|
-
|
6
|
-
def initialize(uri, client, params= {})
|
7
|
-
super uri, client,"fileSet", params
|
8
|
-
@uri, @client = uri, client
|
9
|
-
sub_items :files
|
10
|
-
end
|
11
|
-
end
|
10
|
+
end
|
12
11
|
end
|
data/lib/testdroid_api/files.rb
CHANGED
@@ -1,60 +1,59 @@
|
|
1
|
-
|
2
1
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
2
|
+
class Files < CloudResource
|
3
|
+
def initialize(uri, client, params= {})
|
4
|
+
super uri, client, "files", params
|
5
|
+
@uri, @client = uri, client
|
6
|
+
end
|
7
|
+
|
8
|
+
def uploadApplication(filename)
|
9
|
+
if !File.exist?(filename)
|
10
|
+
@client.logger.error("Invalid filename")
|
11
|
+
return
|
12
|
+
end
|
13
|
+
reply = @client.upload("#{@uri}/application", filename)
|
14
|
+
|
15
|
+
Application.new(nil, nil, reply)
|
16
|
+
end
|
17
|
+
|
18
|
+
def uploadData(filename)
|
19
|
+
if !File.exist?(filename)
|
20
|
+
@client.logger.error("Invalid filename")
|
21
|
+
return
|
22
|
+
end
|
23
|
+
reply = @client.upload("#{@uri}/data", filename)
|
24
|
+
|
25
|
+
Data.new(nil, nil, reply)
|
26
|
+
end
|
27
|
+
|
28
|
+
def uploadTest(filename)
|
29
|
+
if !File.exist?(filename)
|
30
|
+
@client.logger.error("Invalid filename")
|
31
|
+
return
|
32
|
+
end
|
33
|
+
reply = @client.upload("#{@uri}/test", filename)
|
34
|
+
|
35
|
+
Test.new(nil, nil, reply)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
class Application < CloudResource
|
39
|
+
def initialize(uri, client, params= {})
|
40
|
+
super uri, client, "app", params
|
41
|
+
@uri, @client = uri, client
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
class Test < CloudResource
|
46
|
+
def initialize(uri, client, params= {})
|
47
|
+
super uri, client, "test", params
|
48
|
+
@uri, @client = uri, client
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
class Data < CloudResource
|
53
|
+
def initialize(uri, client, params= {})
|
54
|
+
super uri, client, "data", params
|
55
|
+
@uri, @client = uri, client
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
60
59
|
end
|
@@ -1,13 +1,12 @@
|
|
1
|
-
|
2
1
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
class LabelGroups < CloudListResource
|
3
|
+
end
|
4
|
+
class LabelGroup < CloudResource
|
5
|
+
def initialize(uri, client, params= {})
|
6
|
+
super uri, client, "labelGroup", params
|
7
|
+
@uri, @client = uri, client
|
8
|
+
sub_items :labels
|
9
|
+
end
|
11
10
|
|
12
|
-
|
11
|
+
end
|
13
12
|
end
|
data/lib/testdroid_api/labels.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
|
2
1
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
class Labels < CloudListResource
|
3
|
+
end
|
4
|
+
class Label < CloudResource
|
5
|
+
def initialize(uri, client, params= {})
|
6
|
+
super uri, client, "label", params
|
7
|
+
@uri, @client = uri, client
|
8
|
+
sub_items :devices
|
9
|
+
end
|
11
10
|
|
12
|
-
|
11
|
+
end
|
13
12
|
end
|
@@ -1,11 +1,10 @@
|
|
1
|
-
|
2
1
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
class Parameters < CloudListResource
|
3
|
+
end
|
4
|
+
class Parameter < CloudResource
|
5
|
+
def initialize(uri, client, params= {})
|
6
|
+
super uri, client, "parameter", params
|
7
|
+
end
|
9
8
|
|
10
|
-
|
9
|
+
end
|
11
10
|
end
|
@@ -1,21 +1,19 @@
|
|
1
|
-
|
2
1
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
2
|
+
class Projects < CloudListResource
|
3
|
+
end
|
5
4
|
|
6
|
-
|
5
|
+
class Project < CloudResource
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
#Start a new test run
|
14
|
-
#run_parameters - example {:params => {'name' => 'test'}}
|
15
|
-
def run(run_parameters={:params => {}})
|
16
|
-
resp = @client.post("#{@uri}/runs", run_parameters)
|
17
|
-
Run.new("#{@uri}/runs/#{resp['id']}", @client, resp)
|
18
|
-
end
|
7
|
+
def initialize(uri, client, params= {})
|
8
|
+
super uri, client, "project", params
|
9
|
+
@uri, @client = uri, client
|
10
|
+
sub_items :runs, :files, :config
|
11
|
+
end
|
19
12
|
|
13
|
+
def run(run_parameters = {})
|
14
|
+
resp = @client.post("#{@uri}/runs", run_parameters)
|
15
|
+
Run.new("#{@uri}/runs/#{resp['id']}", @client, resp)
|
20
16
|
end
|
17
|
+
|
18
|
+
end
|
21
19
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module TestdroidAPI
|
2
|
+
class Properties < CloudListResource
|
3
|
+
def initialize(uri, client)
|
4
|
+
super uri, client, "Property"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
class Property < CloudResource
|
8
|
+
def initialize(uri, client, params= {})
|
9
|
+
super uri, client, "property", params
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
data/lib/testdroid_api/runs.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
module TestdroidAPI
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
2
|
+
class Runs < CloudListResource
|
3
|
+
end
|
4
|
+
class Run < CloudResource
|
5
|
+
def initialize(uri, client, params= {})
|
6
|
+
super uri, client, "run", params
|
7
|
+
@uri, @client = uri, client
|
8
|
+
sub_items :device_runs
|
9
|
+
end
|
10
|
+
|
11
|
+
def abort()
|
12
|
+
@client.post("#{@uri}/abort", params= {})
|
13
|
+
end
|
14
|
+
end
|
14
15
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module TestdroidAPI
|
2
|
+
class Services < CloudListResource
|
3
|
+
end
|
4
|
+
class Service < CloudResource
|
5
|
+
def initialize(uri, client, params= {})
|
6
|
+
super uri, client, "service", params
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_available
|
10
|
+
@client.get("#{@uri}/available")
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_purchased
|
14
|
+
@client.get("#{@uri}/purchased")
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/testdroid_api/user.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module TestdroidAPI
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
class User < CloudResource
|
3
|
+
def initialize(uri, client, params={})
|
4
|
+
super uri, client, "users", params
|
5
|
+
sub_items :projects, :device_groups, :device_sessions, :file_sets
|
6
|
+
end
|
7
|
+
end
|
8
8
|
end
|
data/sample/sample.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
require 'testdroid-api-client'
|
2
2
|
|
3
|
-
client = TestdroidAPI::Client.new('
|
3
|
+
#client = TestdroidAPI::Client.new(ENV['TESTDROID_USERNAME'],ENV['TESTDROID_PASSWORD'])
|
4
|
+
#or using api key:
|
5
|
+
client = TestdroidAPI::ApikeyClient.new(ENV['TESTDROID_APIKEY'])
|
4
6
|
#to use private cloud specify cloud url as:
|
5
|
-
#client = TestdroidAPI::Client.new('
|
6
|
-
#oauth
|
7
|
+
#client = TestdroidAPI::Client.new('API_KEY', 'https://customer.testdroid.com')
|
7
8
|
user = client.authorize
|
8
9
|
|
9
10
|
# Create Android project
|
10
|
-
android_project = user.projects.create({:
|
11
|
+
android_project = user.projects.create({:name => "Android robotium", :type => "ANDROID"})
|
11
12
|
|
12
13
|
# Create iOS project
|
13
|
-
ios_project = user.projects.create({:
|
14
|
+
ios_project = user.projects.create({:name => "iOS project", :type => "IOS"})
|
14
15
|
|
15
16
|
#Android applicaiton
|
16
|
-
android_project.files.uploadApplication("BitbarSampleApp.apk")
|
17
|
+
file_app = android_project.files.uploadApplication("BitbarSampleApp.apk")
|
17
18
|
|
18
19
|
#instrumentation package
|
19
|
-
android_project.files.uploadTest("
|
20
|
-
|
20
|
+
file_test = android_project.files.uploadTest("BitbarSampleAppTest.apk")
|
21
21
|
|
22
22
|
#Set custom runner and set mode for instrumentaiton test
|
23
|
-
android_project.config.update({
|
23
|
+
android_project.config.update({'instrumentationRunner' => 'com.testrunners.MyRunner', :mode=> 'FULL_RUN'})
|
24
24
|
|
25
25
|
#get all the Android devices
|
26
26
|
android_devices = client.devices.list.select {|device| device.os_type.casecmp("ANDROID") == 0 }
|
@@ -28,7 +28,12 @@ android_devices = client.devices.list.select {|device| device.os_type.casecmp("A
|
|
28
28
|
#get IDs of the android devices
|
29
29
|
id_list = android_devices.collect{|device| device.id }
|
30
30
|
|
31
|
-
run_parameters = {
|
31
|
+
run_parameters = {
|
32
|
+
:name => 'Test run 1',
|
33
|
+
"usedDeviceIds[]" => id_list.join(','),
|
34
|
+
:appFileId => file_app.id,
|
35
|
+
:testFileId => file_test.id
|
36
|
+
}
|
32
37
|
#Run project using the parameters
|
33
38
|
android_project.run(run_parameters)
|
34
39
|
|
@@ -36,4 +41,4 @@ android_project.run(run_parameters)
|
|
36
41
|
sleep 20 until android_project.runs.list.first.state == "FINISHED"
|
37
42
|
|
38
43
|
#download junit xml from the all device runs
|
39
|
-
android_project.runs.list.first.device_runs.list({:
|
44
|
+
android_project.runs.list.first.device_runs.list({:limit => 0}).each { |device_run| device_run.download_junit("#{device_run.id}_junit.xml") }
|