testdroid-api-client 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -9
- data/lib/testdroid-api-client.rb +1 -1
- data/lib/testdroid_api/client.rb +74 -73
- data/lib/testdroid_api/cloud_list_resource.rb +74 -74
- data/lib/testdroid_api/cloud_resource.rb +65 -60
- data/lib/testdroid_api/device_groups.rb +8 -8
- data/lib/testdroid_api/device_runs.rb +17 -17
- data/lib/testdroid_api/device_sessions.rb +10 -10
- data/lib/testdroid_api/devices.rb +9 -9
- data/lib/testdroid_api/file_sets.rb +12 -0
- data/lib/testdroid_api/files.rb +50 -50
- data/lib/testdroid_api/label_groups.rb +9 -9
- data/lib/testdroid_api/labels.rb +9 -9
- data/lib/testdroid_api/projects.rb +1 -1
- data/lib/testdroid_api/runs.rb +8 -8
- data/lib/testdroid_api/user.rb +3 -3
- data/pkg/testdroid-api-client-0.1.2.gem +0 -0
- data/spec/client_spec.rb +1 -1
- data/spec/device_groups_spec.rb +3 -3
- data/spec/device_runs_spec.rb +2 -2
- data/spec/file_sets_spec.rb +47 -0
- data/spec/files_spec.rb +2 -2
- data/spec/fixtures/cassettes/f_add_file_set.json +1 -0
- data/spec/fixtures/cassettes/f_file_sets.json +1 -0
- data/spec/fixtures/cassettes/fs_add_file_set.json +1 -0
- data/spec/fixtures/cassettes/fs_add_file_to_fileset.json +1 -0
- data/spec/fixtures/cassettes/fs_delete_file_set.json +1 -0
- data/spec/fixtures/cassettes/fs_file_sets.json +1 -0
- data/spec/fixtures/cassettes/fs_get_file_set.json +1 -0
- data/spec/fixtures/cassettes/fs_oauth2_auth_files.json +1 -0
- data/spec/fixtures/cassettes/fs_update_file_set.json +1 -0
- data/spec/fixtures/cassettes/p_create_project.json +1 -0
- data/spec/fixtures/cassettes/p_oauth2_local.json +1 -0
- data/spec/label_groups_spec.rb +3 -3
- data/spec/project_spec.rb +17 -4
- data/spec/run_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -2
- data/testdroid-api-client.gemspec +3 -2
- metadata +45 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d02abbd4ba89be9aba2b1c88c23d148b8fc1b892
|
4
|
+
data.tar.gz: 60e430d6b84cfbb80301e349aa26113b43953f22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 556edc82403e13452d74aed3f0950aaa27aabb4e8a2cc5b23c469c38d297f2eea865cc22c531907a641ec02034e8bb2091528d99ff9e962de6a2dc25b943f5aa
|
7
|
+
data.tar.gz: 21693e39ae96d8f405858acc27034fd24ed88fdb3c547699fd2cf50302dfe08d524c55711f6025da4ba11655d92d8f246c1cc11502d4cd73dc734611d1d76b07
|
data/README.md
CHANGED
@@ -1,29 +1,53 @@
|
|
1
|
-
|
1
|
+
Testdroid API Client for Ruby
|
2
2
|
=========================
|
3
3
|
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
# Gemfile
|
9
|
+
gem "testdroid-api-client"
|
4
10
|
```
|
11
|
+
|
12
|
+
```bash
|
13
|
+
> bundle install
|
14
|
+
```
|
15
|
+
## Sample client usage - Authenticate
|
16
|
+
```ruby
|
5
17
|
require 'testdroid-api-client'
|
6
|
-
|
7
|
-
|
18
|
+
|
19
|
+
client = TestdroidAPI::Client.new('admin@localhost', 'admin')
|
20
|
+
```
|
21
|
+
## Sample usage - get projects
|
22
|
+
```ruby
|
8
23
|
@user = client.authorize
|
9
|
-
#get Projects
|
10
24
|
projects = @user.projects.list
|
11
|
-
|
12
|
-
|
25
|
+
```
|
26
|
+
## Get project by id
|
27
|
+
```ruby
|
13
28
|
project_id = 123
|
14
29
|
project123 = @user.projects.get(project_id)
|
15
30
|
#output project name
|
16
31
|
p "Project name #{project123.name}"
|
32
|
+
```
|
17
33
|
|
18
|
-
|
34
|
+
## Start project
|
35
|
+
```ruby
|
19
36
|
test_run = project123.run
|
37
|
+
```
|
20
38
|
|
21
|
-
|
39
|
+
## Check test run status
|
40
|
+
```ruby
|
22
41
|
p "Project state #{test_run.state}"
|
23
42
|
|
24
|
-
|
43
|
+
```
|
44
|
+
## Download all logs from test run
|
45
|
+
```ruby
|
25
46
|
test_run.device_runs.list({:params => {:limit => 100}}).each { |drun| drun.download_logs("#{drun.id}_log") }
|
47
|
+
```
|
26
48
|
|
49
|
+
## Using device labels
|
50
|
+
```ruby
|
27
51
|
#Get label for android os version 2.1
|
28
52
|
lg_android_version_2_1 = client.label_groups.list.detect {|lg| lg.display_name.casecmp("android version") == 0 }
|
29
53
|
|
@@ -34,6 +58,17 @@ os_v2_1 = client.label_groups.get(lg_android_versions.id).labels.list.detect {|
|
|
34
58
|
#get spefici device from devices list
|
35
59
|
lenovo_a820 = devices.list.detect {|d| d.display_name == "Lenovo A820"}
|
36
60
|
|
61
|
+
|
62
|
+
```
|
63
|
+
Device Sessions
|
64
|
+
----
|
65
|
+
```
|
66
|
+
To create a new device session:
|
67
|
+
device_session = user.device_sessions.create({:params => {'deviceModelId' => '1'}})
|
68
|
+
|
69
|
+
To release device session:
|
70
|
+
device_session.release()
|
37
71
|
|
38
72
|
```
|
73
|
+
|
39
74
|
See https://cloud.testdroid.com/swagger/index.html for more details about API V2
|
data/lib/testdroid-api-client.rb
CHANGED
data/lib/testdroid_api/client.rb
CHANGED
@@ -10,9 +10,9 @@ module TestdroidAPI
|
|
10
10
|
ACCEPT_HEADERS={'Accept' => 'application/json'}
|
11
11
|
|
12
12
|
def initialize(username, password, cloud_url = CLOUD_ENDPOINT, logger = nil)
|
13
|
-
# Instance variables
|
14
|
-
@username = username
|
15
|
-
@password = password
|
13
|
+
# Instance variables
|
14
|
+
@username = username
|
15
|
+
@password = password
|
16
16
|
@cloud_url = cloud_url
|
17
17
|
@logger = logger
|
18
18
|
|
@@ -20,52 +20,52 @@ module TestdroidAPI
|
|
20
20
|
@logger = Logger.new(STDOUT)
|
21
21
|
@logger.info("Logger is not defined => output to STDOUT")
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end
|
24
24
|
def label_groups
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
label_groups = TestdroidAPI::LabelGroups.new( "/#{API_VERSION}/label-groups", self )
|
26
|
+
label_groups.list
|
27
|
+
label_groups
|
28
28
|
end
|
29
29
|
def devices
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
30
|
+
devices = TestdroidAPI::Devices.new( "/#{API_VERSION}/devices", self )
|
31
|
+
devices.list
|
32
|
+
devices
|
33
|
+
end
|
34
34
|
def authorize
|
35
35
|
|
36
36
|
@client = OAuth2::Client.new('testdroid-cloud-api', nil, :site => @cloud_url, :authorize_url => 'oauth/authorize',
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
:token_url => 'oauth/token', :headers => ACCEPT_HEADERS) do |faraday|
|
38
|
+
faraday.request :multipart
|
39
|
+
faraday.request :url_encoded
|
40
|
+
faraday.response :logger, @logger
|
41
|
+
faraday.adapter Faraday.default_adapter
|
42
|
+
end
|
43
|
+
|
44
44
|
@token = @client.password.get_token(@username, @password, :headers => ACCEPT_HEADERS)
|
45
|
-
|
45
|
+
|
46
46
|
if (@cloud_user.nil?)
|
47
|
-
|
48
|
-
|
47
|
+
@cloud_user = TestdroidAPI::User.new( "/#{API_VERSION}/me", self ).refresh
|
48
|
+
@cloud_user = TestdroidAPI::User.new( "/#{API_VERSION}/users/#{@cloud_user.id}", self ).refresh
|
49
49
|
|
50
|
-
|
50
|
+
end
|
51
51
|
@cloud_user
|
52
52
|
end
|
53
|
-
def upload(uri, filename, file_type)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
53
|
+
def upload(uri, filename, file_type)
|
54
|
+
begin
|
55
|
+
@token.refresh!(:headers => ACCEPT_HEADERS) if @token.expired?
|
56
|
+
connection = @token.client.connection
|
57
|
+
payload = {:file => Faraday::UploadIO.new(filename, file_type) }
|
58
|
+
headers = ACCEPT_HEADERS.merge(@token.headers)
|
59
|
+
response = connection.post(@cloud_url+"#{uri}",payload, headers)
|
60
|
+
rescue => e
|
61
|
+
@logger.error e
|
62
|
+
return nil
|
63
|
+
end
|
64
|
+
JSON.parse(response.body)
|
65
65
|
end
|
66
|
-
def post(uri, params)
|
67
|
-
|
68
|
-
@token
|
66
|
+
def post(uri, params)
|
67
|
+
|
68
|
+
@token.refresh!(:headers => ACCEPT_HEADERS) if @token.expired?
|
69
69
|
|
70
70
|
begin
|
71
71
|
resp = @token.post("#{@cloud_url}#{uri}", params.merge(:headers => ACCEPT_HEADERS))
|
@@ -73,44 +73,45 @@ module TestdroidAPI
|
|
73
73
|
@logger.error "Failed to post resource #{uri} #{e}"
|
74
74
|
return nil
|
75
75
|
end
|
76
|
-
|
77
|
-
end
|
78
|
-
def get(uri, params={})
|
79
|
-
|
80
|
-
@logger.error "token expired" if @token.expired?
|
81
|
-
|
82
|
-
@token = @client.password.get_token(@username, @password) if @token.expired?
|
83
|
-
|
84
|
-
begin
|
85
|
-
resp = @token.get(@cloud_url+"#{uri}", params.merge(:headers => ACCEPT_HEADERS))
|
86
|
-
rescue => e
|
87
|
-
@logger.error "Failed to get resource #{uri} #{e}"
|
88
|
-
return nil
|
89
|
-
end
|
90
|
-
JSON.parse(resp.body)
|
76
|
+
JSON.parse(resp.body)
|
91
77
|
end
|
92
|
-
def
|
93
|
-
|
94
|
-
@logger.error "token expired" if @token.expired?
|
95
|
-
|
96
|
-
@token = @client.password.get_token(@username, @password) if @token.expired?
|
97
|
-
|
98
|
-
begin
|
99
|
-
resp = @token.delete(@cloud_url+"#{uri}", :headers => ACCEPT_HEADERS )
|
100
|
-
rescue => e
|
101
|
-
@logger.error "Failed to delete resource #{uri} #{e}"
|
102
|
-
return nil
|
103
|
-
end
|
78
|
+
def get(uri, params={})
|
104
79
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
80
|
+
@logger.error "token expired" if @token.expired?
|
81
|
+
|
82
|
+
@token.refresh!(:headers => ACCEPT_HEADERS) if @token.expired?
|
83
|
+
|
84
|
+
begin
|
85
|
+
resp = @token.get(@cloud_url+"#{uri}", params.merge(:headers => ACCEPT_HEADERS))
|
86
|
+
rescue => e
|
87
|
+
@logger.error "Failed to get resource #{uri} #{e}"
|
88
|
+
return nil
|
89
|
+
end
|
90
|
+
JSON.parse(resp.body)
|
91
|
+
end
|
92
|
+
def delete(uri)
|
93
|
+
|
94
|
+
@logger.error "token expired" if @token.expired?
|
95
|
+
|
96
|
+
@token.refresh!(:headers => ACCEPT_HEADERS) if @token.expired?
|
97
|
+
|
98
|
+
begin
|
99
|
+
resp = @token.delete(@cloud_url+"#{uri}", :headers => ACCEPT_HEADERS )
|
100
|
+
rescue => e
|
101
|
+
@logger.error "Failed to delete resource #{uri} #{e}"
|
102
|
+
return nil
|
103
|
+
end
|
104
|
+
|
105
|
+
if (resp.status != 204)
|
106
|
+
@logger.error "Failed to delete resource #{uri} #{e}"
|
107
|
+
return nil
|
108
|
+
else
|
109
|
+
@logger.info "response: #{resp.status}"
|
110
|
+
end
|
111
111
|
end
|
112
112
|
def download(uri, file_name)
|
113
|
-
begin
|
113
|
+
begin
|
114
|
+
@token.refresh!(:headers => ACCEPT_HEADERS) if @token.expired?
|
114
115
|
File.open(file_name, "w+b") do |file|
|
115
116
|
resp = @token.get("#{@cloud_url}/#{uri}", :headers => ACCEPT_HEADERS)
|
116
117
|
file.write(resp.body)
|
@@ -119,6 +120,6 @@ module TestdroidAPI
|
|
119
120
|
@logger.error "Failed to get resource #{uri} #{e}"
|
120
121
|
return nil
|
121
122
|
end
|
122
|
-
end
|
123
|
+
end
|
123
124
|
end
|
124
|
-
end
|
125
|
+
end
|
@@ -1,83 +1,83 @@
|
|
1
1
|
|
2
2
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
class CloudListResource
|
4
|
+
|
5
|
+
def initialize(uri, client)
|
6
|
+
@uri, @client = uri, client
|
7
|
+
resource_name = self.class.name.split('::')[-1]
|
8
|
+
@instance_class = TestdroidAPI.const_get resource_name.chop
|
9
|
+
@list_key, @instance_id_key = resource_name.gsub!(/\b\w/) { $&.downcase } , 'id'
|
10
|
+
end
|
11
|
+
def get(resource_id)
|
12
|
+
@instance_class.new( "#{@uri}/#{resource_id}", @client)
|
13
|
+
end
|
14
|
+
def total
|
15
|
+
|
16
|
+
@client.get(@uri)['total']
|
17
|
+
end
|
18
|
+
def create(params={})
|
19
|
+
raise "Can't create a resource without a REST Client" unless @client
|
20
|
+
response = @client.post @uri, params
|
21
|
+
@instance_class.new "#{@uri}/#{response[@instance_id_key]}", @client,
|
22
|
+
response
|
23
|
+
end
|
24
|
+
def list_all()
|
25
|
+
raise "Can't get a resource list without a REST Client" unless @client
|
26
|
+
|
27
|
+
response = @client.get("#{@uri}?limit=355043550", {})
|
28
|
+
|
29
|
+
if response['data'].is_a?(Array)
|
30
|
+
client = @client
|
31
|
+
class_list = []
|
32
|
+
list_class = self.class
|
33
|
+
instance_uri = @uri
|
34
|
+
response['data'].each do |val|
|
35
|
+
|
36
|
+
class_list << @instance_class.new( "#{instance_uri}/#{val[@instance_id_key]}", @client, val)
|
37
|
+
end
|
13
38
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
response
|
28
|
-
|
29
|
-
|
30
|
-
client = @client
|
31
|
-
class_list = []
|
32
|
-
list_class = self.class
|
33
|
-
instance_uri = @uri
|
34
|
-
response['data'].each do |val|
|
35
|
-
|
36
|
-
class_list << @instance_class.new( "#{instance_uri}/#{val[@instance_id_key]}", @client, val)
|
37
|
-
end
|
39
|
+
class_list
|
40
|
+
end
|
41
|
+
def list(params={}, full_uri=false)
|
42
|
+
raise "Can't get a resource list without a REST Client" unless @client
|
43
|
+
@uri = full_uri ? @uri.split(@client.instance_variable_get(:@cloud_url))[1] : @uri
|
44
|
+
|
45
|
+
response = @client.get(@uri, params)
|
46
|
+
|
47
|
+
if response['data'].is_a?(Array)
|
48
|
+
client = @client
|
49
|
+
class_list = []
|
50
|
+
list_class = self.class
|
51
|
+
instance_uri = full_uri ? @uri.split('?')[0] : @uri
|
52
|
+
response['data'].each do |val|
|
53
|
+
|
54
|
+
class_list << @instance_class.new( "#{instance_uri}/#{val[@instance_id_key]}", @client, val)
|
38
55
|
end
|
39
|
-
class_list
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
56
|
+
class_list.instance_eval do
|
57
|
+
eigenclass = class << self; self; end
|
58
|
+
|
59
|
+
eigenclass.send :define_method, :offset, &lambda {response['offset']}
|
60
|
+
eigenclass.send :define_method, :limit, &lambda {response['limit']}
|
61
|
+
eigenclass.send :define_method, :total, &lambda {response['total']}
|
62
|
+
eigenclass.send :define_method, :next_page, &lambda {
|
63
|
+
if response['next']
|
64
|
+
|
65
|
+
list_class.new(response['next'], client).list({}, true)
|
66
|
+
else
|
67
|
+
[]
|
68
|
+
end
|
69
|
+
}
|
70
|
+
eigenclass.send :define_method, :previous_page, &lambda {
|
71
|
+
if response['previous']
|
44
72
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
list_class = self.class
|
51
|
-
instance_uri = full_uri ? @uri.split('?')[0] : @uri
|
52
|
-
response['data'].each do |val|
|
53
|
-
|
54
|
-
class_list << @instance_class.new( "#{instance_uri}/#{val[@instance_id_key]}", @client, val)
|
55
|
-
end
|
56
|
-
class_list.instance_eval do
|
57
|
-
eigenclass = class << self; self; end
|
58
|
-
|
59
|
-
eigenclass.send :define_method, :offset, &lambda {response['offset']}
|
60
|
-
eigenclass.send :define_method, :limit, &lambda {response['limit']}
|
61
|
-
eigenclass.send :define_method, :total, &lambda {response['total']}
|
62
|
-
eigenclass.send :define_method, :next_page, &lambda {
|
63
|
-
if response['next']
|
64
|
-
|
65
|
-
list_class.new(response['next'], client).list({}, true)
|
66
|
-
else
|
67
|
-
[]
|
68
|
-
end
|
69
|
-
}
|
70
|
-
eigenclass.send :define_method, :previous_page, &lambda {
|
71
|
-
if response['previous']
|
72
|
-
|
73
|
-
list_class.new(response['previous'], client).list({}, true)
|
74
|
-
else
|
75
|
-
[]
|
76
|
-
end
|
77
|
-
}
|
78
|
-
end
|
73
|
+
list_class.new(response['previous'], client).list({}, true)
|
74
|
+
else
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
}
|
79
78
|
end
|
80
|
-
class_list
|
81
79
|
end
|
80
|
+
class_list
|
81
|
+
end
|
82
82
|
end
|
83
83
|
end
|
@@ -1,72 +1,77 @@
|
|
1
1
|
|
2
2
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
self.class.instance_eval {attr_reader *items}
|
21
|
-
end
|
22
|
-
def method_missing(method, *args)
|
23
|
-
super if @updated
|
24
|
-
set_up_properties_from(@client.get(@uri))
|
25
|
-
self.send method, *args
|
3
|
+
class CloudResource
|
4
|
+
def initialize(uri, client, resource_name=nil, params= {})
|
5
|
+
|
6
|
+
@uri, @client, @resource_name = uri, client, resource_name
|
7
|
+
set_up_properties_from( params )
|
8
|
+
end
|
9
|
+
def inspect # :nodoc:
|
10
|
+
"<#{self.class} @uri=#{@uri}>"
|
11
|
+
end
|
12
|
+
def sub_items(*items)
|
13
|
+
items.each do |item|
|
14
|
+
resource = camel_case_it item
|
15
|
+
uri = "#{@uri}/#{item.to_s.gsub('_', '-') }"
|
16
|
+
resource_class = TestdroidAPI.const_get resource
|
17
|
+
new_class = resource_class.new(uri, @client)
|
18
|
+
instance_variable_set( "@#{item}", new_class )
|
26
19
|
end
|
27
|
-
|
20
|
+
self.class.instance_eval {attr_reader *items}
|
21
|
+
end
|
22
|
+
def method_missing(method, *args)
|
23
|
+
super if @updated
|
24
|
+
set_up_properties_from(@client.get(@uri))
|
25
|
+
self.send method, *args
|
26
|
+
end
|
27
|
+
def update(params = {})
|
28
|
+
raise "Can't update a resource without a REST Client" unless @client
|
29
|
+
set_up_properties_from(@client.post(@uri, params))
|
30
|
+
self
|
31
|
+
end
|
32
|
+
def set_up_properties_from(hash)
|
33
|
+
|
34
|
+
eigenclass = class << self; self; end
|
35
|
+
hash.each do |p,v|
|
36
|
+
property = snake_case_it p
|
28
37
|
|
29
|
-
|
30
|
-
hash.each do |p,v|
|
31
|
-
property = snake_case_it p
|
32
|
-
|
33
|
-
unless ['uri', 'client', 'updated'].include? property
|
38
|
+
unless ['uri', 'client', 'updated'].include? property
|
34
39
|
eigenclass.send :define_method, property.to_sym, &lambda {v}
|
35
|
-
end
|
36
40
|
end
|
37
|
-
@updated = !hash.keys.empty?
|
38
|
-
end
|
39
|
-
|
40
|
-
def refresh
|
41
|
-
raise "Can't refresh a resource without a REST Client" unless @client
|
42
|
-
@updated = false
|
43
|
-
set_up_properties_from(@client.get(@uri))
|
44
|
-
self
|
45
41
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
@updated = !hash.keys.empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
def refresh
|
46
|
+
raise "Can't refresh a resource without a REST Client" unless @client
|
47
|
+
@updated = false
|
48
|
+
set_up_properties_from(@client.get(@uri))
|
49
|
+
self
|
50
|
+
end
|
51
|
+
def download_file(file_resource_name, target_file_name=nil)
|
52
|
+
raise "Can't refresh a resource without a REST Client" unless @client
|
53
|
+
target_file_name = file_resource_name unless target_file_name
|
54
|
+
@client.download("#{@uri}/#{file_resource_name}", target_file_name)
|
55
|
+
end
|
56
|
+
def camel_case_it(something)
|
57
|
+
if something.is_a? Hash
|
58
|
+
Hash[*something.to_a.map {|a| [camel_case_it(a[0]).to_sym, a[1]]}.flatten]
|
59
|
+
else
|
60
|
+
something.to_s.split('_').map do |s|
|
56
61
|
[s[0,1].capitalize, s[1..-1]].join
|
57
|
-
|
58
|
-
end
|
59
|
-
end
|
60
|
-
def snake_case_it(something)
|
61
|
-
if something.is_a? Hash
|
62
|
-
Hash[*something.to_a.map {|pair| [snake_case_it(pair[0]).to_sym, pair[1]]}.flatten]
|
63
|
-
else
|
64
|
-
something.to_s.gsub(/[A-Z][a-z]*/) {|s| "_#{s.downcase}"}.gsub(/^_/, '')
|
65
|
-
end
|
62
|
+
end.join
|
66
63
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
end
|
65
|
+
def snake_case_it(something)
|
66
|
+
if something.is_a? Hash
|
67
|
+
Hash[*something.to_a.map {|pair| [snake_case_it(pair[0]).to_sym, pair[1]]}.flatten]
|
68
|
+
else
|
69
|
+
something.to_s.gsub(/[A-Z][a-z]*/) {|s| "_#{s.downcase}"}.gsub(/^_/, '')
|
70
70
|
end
|
71
71
|
end
|
72
|
+
def delete
|
73
|
+
raise "Can't delete a resource without a REST Client" unless @client
|
74
|
+
client.delete(@uri)
|
75
|
+
end
|
76
|
+
end
|
72
77
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
|
2
2
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
3
|
+
class DeviceGroups < CloudListResource
|
4
|
+
end
|
5
|
+
class DeviceGroup < CloudResource
|
6
|
+
def initialize(uri, client, params= {})
|
7
|
+
super uri, client,"deviceGroup", params
|
8
|
+
@uri, @client = uri, client
|
11
9
|
end
|
10
|
+
|
11
|
+
end
|
12
12
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
|
2
2
|
module TestdroidAPI
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
3
|
+
class DeviceRuns < CloudListResource
|
4
|
+
end
|
5
|
+
class DeviceRun < CloudResource
|
6
|
+
def initialize(uri, client, params= {})
|
7
|
+
super uri, client,"deviceRun", params
|
8
|
+
@uri, @client = uri, client
|
9
|
+
end
|
10
|
+
def download_performance(file_name="performance_data.txt")
|
11
|
+
@client.download("#{@uri}/performance", file_name)
|
12
|
+
end
|
13
|
+
def download_junit(file_name="junit.xml")
|
14
|
+
@client.download("#{@uri}/junit.xml", file_name)
|
15
|
+
end
|
16
|
+
def download_logs(file_name="log.txt")
|
17
|
+
@client.download("#{@uri}/logs", file_name)
|
18
|
+
end
|
19
|
+
end
|
20
20
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
|
2
2
|
module TestdroidAPI
|
3
|
-
|
3
|
+
class DeviceSessions < CloudListResource
|
4
|
+
end
|
5
|
+
class DeviceSession < CloudResource
|
6
|
+
def initialize(uri, client, params= {})
|
7
|
+
super uri, client,"deviceSession", params
|
8
|
+
@uri, @client = uri, client
|
4
9
|
end
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@uri, @client = uri, client
|
9
|
-
end
|
10
|
-
def release
|
11
|
-
resp = @client.post("#{@uri}/release", params= {})
|
12
|
-
DeviceSession.new("#{@uri}", @client, resp)
|
13
|
-
end
|
10
|
+
def release
|
11
|
+
resp = @client.post("#{@uri}/release", params= {})
|
12
|
+
DeviceSession.new("#{@uri}", @client, resp)
|
14
13
|
end
|
14
|
+
end
|
15
15
|
end
|