testdroid-api-client 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -2
- data/.travis.yml +8 -0
- data/Gemfile.lock +39 -37
- data/README.md +26 -41
- data/lib/testdroid-api-client.rb +1 -4
- data/lib/testdroid-api-filter-builder.rb +1 -1
- data/lib/testdroid_api/admin.rb +5 -5
- data/lib/testdroid_api/admin_device_models.rb +1 -1
- data/lib/testdroid_api/admin_device_problems.rb +1 -1
- data/lib/testdroid_api/admin_device_statuses.rb +1 -1
- data/lib/testdroid_api/admin_devices.rb +1 -1
- data/lib/testdroid_api/apikey_client.rb +31 -31
- data/lib/testdroid_api/client.rb +39 -47
- data/lib/testdroid_api/cloud_list_resource.rb +11 -15
- data/lib/testdroid_api/cloud_resource.rb +7 -7
- data/lib/testdroid_api/device_groups.rb +2 -1
- data/lib/testdroid_api/device_session_connections.rb +1 -1
- data/lib/testdroid_api/device_sessions.rb +11 -2
- data/lib/testdroid_api/devices.rb +1 -1
- data/lib/testdroid_api/files.rb +8 -47
- data/lib/testdroid_api/frameworks.rb +11 -0
- data/lib/testdroid_api/label_groups.rb +1 -1
- data/lib/testdroid_api/labels.rb +1 -1
- data/lib/testdroid_api/projects.rb +2 -7
- data/lib/testdroid_api/properties.rb +1 -1
- data/lib/testdroid_api/runs.rb +12 -3
- data/lib/testdroid_api/services.rb +1 -1
- data/lib/testdroid_api/user.rb +7 -2
- data/sample/BitbarSampleApp.apk +0 -0
- data/sample/BitbarSampleAppTest.apk +0 -0
- data/sample/sample.rb +22 -27
- data/spec/client_spec.rb +7 -7
- data/spec/device_groups_spec.rb +30 -17
- data/spec/files_spec.rb +29 -20
- data/spec/fixtures/apk.apk +0 -0
- data/spec/fixtures/cassettes/device_groups_authorize.json +1 -0
- data/spec/fixtures/cassettes/device_groups_create.json +1 -0
- data/spec/fixtures/cassettes/device_groups_delete.json +1 -0
- data/spec/fixtures/cassettes/device_groups_get_all.json +1 -0
- data/spec/fixtures/cassettes/device_groups_get_one.json +1 -0
- data/spec/fixtures/cassettes/files_authorize.json +1 -0
- data/spec/fixtures/cassettes/files_delete.json +1 -0
- data/spec/fixtures/cassettes/files_get_all.json +1 -0
- data/spec/fixtures/cassettes/files_get_one.json +1 -0
- data/spec/fixtures/cassettes/files_upload.json +1 -0
- data/spec/fixtures/cassettes/label_groups_authorize.json +1 -0
- data/spec/fixtures/cassettes/label_groups_create.json +1 -0
- data/spec/fixtures/cassettes/label_groups_delete.json +1 -0
- data/spec/fixtures/cassettes/label_groups_get_all.json +1 -0
- data/spec/fixtures/cassettes/label_groups_get_labels.json +1 -0
- data/spec/fixtures/cassettes/label_groups_get_one.json +1 -0
- data/spec/fixtures/cassettes/projects_authorize.json +1 -0
- data/spec/fixtures/cassettes/projects_create.json +1 -0
- data/spec/fixtures/cassettes/projects_delete.json +1 -0
- data/spec/fixtures/cassettes/projects_get_all.json +1 -0
- data/spec/fixtures/cassettes/projects_get_one.json +1 -0
- data/spec/fixtures/cassettes/runs_abort_run.json +1 -0
- data/spec/fixtures/cassettes/runs_authorize.json +1 -0
- data/spec/fixtures/cassettes/runs_get_project_runs.json +1 -0
- data/spec/fixtures/cassettes/runs_start_run.json +1 -0
- data/spec/label_groups_spec.rb +35 -42
- data/spec/projects_spec.rb +41 -0
- data/spec/runs_spec.rb +41 -0
- data/spec/spec_helper.rb +3 -4
- data/testdroid-api-client.gemspec +12 -12
- metadata +53 -162
- data/lib/testdroid_api/config.rb +0 -9
- data/lib/testdroid_api/device_runs.rb +0 -22
- data/lib/testdroid_api/file_sets.rb +0 -11
- data/lib/testdroid_api/parameters.rb +0 -10
- data/spec/device_runs_spec.rb +0 -25
- data/spec/file_sets_spec.rb +0 -47
- data/spec/fixtures/cassettes/dg_all_device_groups.json +0 -1
- data/spec/fixtures/cassettes/dg_device_group_4165.json +0 -1
- data/spec/fixtures/cassettes/dg_oauth2_auth_device_groups.json +0 -1
- data/spec/fixtures/cassettes/dr_all_run_171221_device_runs.json +0 -1
- data/spec/fixtures/cassettes/dr_device_run_33044722.json +0 -1
- data/spec/fixtures/cassettes/dr_oauth2_auth_device_runs.json +0 -1
- data/spec/fixtures/cassettes/dr_run_33044722_device_runs.json +0 -1
- data/spec/fixtures/cassettes/f_add_file_set.json +0 -1
- data/spec/fixtures/cassettes/f_android_app_file.json +0 -1
- data/spec/fixtures/cassettes/f_file_sets.json +0 -1
- data/spec/fixtures/cassettes/f_oauth2_auth_files.json +0 -1
- data/spec/fixtures/cassettes/f_upload_files.json +0 -1
- data/spec/fixtures/cassettes/fs_add_file_set.json +0 -1
- data/spec/fixtures/cassettes/fs_add_file_to_fileset.json +0 -1
- data/spec/fixtures/cassettes/fs_delete_file_set.json +0 -1
- data/spec/fixtures/cassettes/fs_file_sets.json +0 -1
- data/spec/fixtures/cassettes/fs_get_file_set.json +0 -1
- data/spec/fixtures/cassettes/fs_oauth2_auth_files.json +0 -1
- data/spec/fixtures/cassettes/fs_update_file_set.json +0 -1
- data/spec/fixtures/cassettes/fu_oauth2_auth_files.json +0 -1
- data/spec/fixtures/cassettes/lg_all_label_groups.json +0 -1
- data/spec/fixtures/cassettes/lg_get_resources_by_label.json +0 -1
- data/spec/fixtures/cassettes/lg_label_group_1058800.json +0 -1
- data/spec/fixtures/cassettes/lg_labels_of_group_1058800.json +0 -1
- data/spec/fixtures/cassettes/lg_oauth2_auth_label_groups.json +0 -1
- data/spec/fixtures/cassettes/p_all_projects.json +0 -1
- data/spec/fixtures/cassettes/p_create_project.json +0 -1
- data/spec/fixtures/cassettes/p_get_run_devices.json +0 -1
- data/spec/fixtures/cassettes/p_oauth2_auth.json +0 -1
- data/spec/fixtures/cassettes/p_oauth2_local.json +0 -1
- data/spec/fixtures/cassettes/p_project_id_33029366.json +0 -1
- data/spec/fixtures/cassettes/p_run_project.json +0 -1
- data/spec/fixtures/cassettes/pc_get_current.json +0 -1
- data/spec/fixtures/cassettes/pc_oauth2_auth_config.json +0 -1
- data/spec/fixtures/cassettes/pc_set_current_config.json +0 -1
- data/spec/fixtures/cassettes/pc_validate_config.json +0 -1
- data/spec/fixtures/cassettes/pcp_delete_params.json +0 -1
- data/spec/fixtures/cassettes/pcp_get_current.json +0 -1
- data/spec/fixtures/cassettes/pcp_oauth2_auth_config.json +0 -1
- data/spec/fixtures/cassettes/pcp_set_current_config.json +0 -1
- data/spec/fixtures/cassettes/pcp_validate_config.json +0 -1
- data/spec/fixtures/cassettes/r_all_project_33029366_runs.json +0 -1
- data/spec/fixtures/cassettes/r_delete_test_run.json +0 -1
- data/spec/fixtures/cassettes/r_oauth2_auth_runs.json +0 -1
- data/spec/fixtures/cassettes/r_run_171221.json +0 -1
- data/spec/fixtures/cassettes/r_run_project.json +0 -1
- data/spec/fixtures/cassettes/upload_files.json +0 -1
- data/spec/fixtures/project.json +0 -8
- data/spec/project_config_parameters_spec.rb +0 -44
- data/spec/project_config_spec.rb +0 -36
- data/spec/project_spec.rb +0 -56
- data/spec/run_spec.rb +0 -33
data/lib/testdroid_api/client.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
module TestdroidAPI
|
2
2
|
|
3
|
-
class Client
|
3
|
+
class Client
|
4
4
|
attr_reader :config
|
5
5
|
attr_accessor :logger
|
6
6
|
attr_reader :token
|
7
7
|
|
8
8
|
API_VERSION = 'api/v2'
|
9
|
-
CLOUD_ENDPOINT='https://cloud.
|
10
|
-
ACCEPT_HEADERS={'Accept' => 'application/json'}
|
9
|
+
CLOUD_ENDPOINT = 'https://cloud.bitbar.com'
|
11
10
|
|
12
11
|
def initialize(username, password, cloud_url = CLOUD_ENDPOINT, logger = nil)
|
13
12
|
# Instance variables
|
@@ -21,106 +20,99 @@ class Client
|
|
21
20
|
@logger.info("Logger is not defined => output to STDOUT")
|
22
21
|
end
|
23
22
|
end
|
24
|
-
def label_groups
|
25
|
-
label_groups = TestdroidAPI::LabelGroups.new( "/#{API_VERSION}/label-groups", self )
|
26
|
-
label_groups.list
|
27
|
-
label_groups
|
28
|
-
end
|
29
|
-
def devices
|
30
|
-
devices = TestdroidAPI::Devices.new( "/#{API_VERSION}/devices", self )
|
31
|
-
devices.list
|
32
|
-
devices
|
33
|
-
end
|
34
|
-
def authorize
|
35
23
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
faraday.request
|
24
|
+
def authorize
|
25
|
+
@client = OAuth2::Client.new(
|
26
|
+
'testdroid-cloud-api', nil, :site => @cloud_url, :token_url => 'oauth/token') do |faraday|
|
27
|
+
faraday.request :multipart
|
28
|
+
faraday.request :url_encoded
|
40
29
|
faraday.response :logger, @logger
|
41
|
-
faraday.adapter
|
30
|
+
faraday.adapter Faraday.default_adapter
|
42
31
|
end
|
43
32
|
|
44
|
-
@token = @client.password.get_token(@username, @password
|
33
|
+
@token = @client.password.get_token(@username, @password)
|
45
34
|
|
46
|
-
if
|
47
|
-
@cloud_user = TestdroidAPI::User.new(
|
48
|
-
@cloud_user = TestdroidAPI::User.new(
|
35
|
+
if @cloud_user.nil?
|
36
|
+
@cloud_user = TestdroidAPI::User.new("/#{API_VERSION}/me", self).refresh
|
37
|
+
@cloud_user = TestdroidAPI::User.new("/#{API_VERSION}/users/#{@cloud_user.id}", self).refresh
|
49
38
|
|
50
39
|
end
|
51
40
|
@cloud_user
|
52
41
|
end
|
53
42
|
|
54
43
|
def mime_for(path)
|
55
|
-
|
56
|
-
|
44
|
+
mime = MIME::Types.type_for path
|
45
|
+
mime.empty? ? 'text/plain' : mime[0].content_type
|
57
46
|
end
|
58
47
|
|
59
48
|
def upload(uri, filename)
|
60
49
|
begin
|
61
|
-
@token = @token.refresh!
|
50
|
+
@token = @token.refresh! if @token.expired?
|
62
51
|
connection = @token.client.connection
|
63
|
-
payload = {:file
|
64
|
-
|
65
|
-
response = connection.post(@cloud_url+"#{uri}",payload, headers)
|
52
|
+
payload = {:file => Faraday::UploadIO.new(filename, mime_for(filename))}
|
53
|
+
response = connection.post(@cloud_url + "#{uri}", payload, @token.headers)
|
66
54
|
rescue => e
|
67
55
|
@logger.error e
|
68
56
|
return nil
|
69
57
|
end
|
70
58
|
JSON.parse(response.body)
|
71
59
|
end
|
72
|
-
def post(uri, params)
|
73
60
|
|
74
|
-
|
61
|
+
def post(uri, params = {})
|
62
|
+
|
63
|
+
@token = @token.refresh! if @token.expired?
|
75
64
|
|
76
65
|
begin
|
77
|
-
resp = @token.post("#{@cloud_url}#{uri}", params
|
66
|
+
resp = @token.post("#{@cloud_url}#{uri}", params)
|
78
67
|
rescue => e
|
79
68
|
@logger.error "Failed to post resource #{uri} #{e}"
|
80
69
|
return nil
|
81
70
|
end
|
82
|
-
|
71
|
+
|
83
72
|
if resp.body.nil? || resp.body.length == 0
|
84
73
|
return nil
|
85
74
|
end
|
86
|
-
|
75
|
+
|
87
76
|
JSON.parse(resp.body)
|
88
77
|
end
|
89
|
-
def get(uri, params={})
|
90
78
|
|
91
|
-
|
79
|
+
def get(uri, params = {})
|
80
|
+
|
81
|
+
@token = @token.refresh! if @token.expired?
|
92
82
|
|
93
83
|
begin
|
94
|
-
resp = @token.get(@cloud_url+"#{uri}", params
|
84
|
+
resp = @token.get(@cloud_url + "#{uri}", :params => params)
|
95
85
|
rescue => e
|
96
86
|
@logger.error "Failed to get resource #{uri} #{e}"
|
97
87
|
return nil
|
98
88
|
end
|
99
89
|
JSON.parse(resp.body)
|
100
90
|
end
|
91
|
+
|
101
92
|
def delete(uri)
|
102
93
|
|
103
|
-
@token = @token.refresh!
|
94
|
+
@token = @token.refresh! if @token.expired?
|
104
95
|
|
105
96
|
begin
|
106
|
-
resp = @token.delete(@cloud_url+"#{uri}"
|
97
|
+
resp = @token.delete(@cloud_url + "#{uri}")
|
107
98
|
rescue => e
|
108
99
|
@logger.error "Failed to delete resource #{uri} #{e}"
|
109
100
|
return nil
|
110
101
|
end
|
111
102
|
|
112
|
-
if
|
103
|
+
if resp.status != 204
|
113
104
|
@logger.error "Failed to delete resource #{uri} #{e}"
|
114
|
-
return nil
|
115
105
|
else
|
116
106
|
@logger.info "response: #{resp.status}"
|
117
107
|
end
|
118
108
|
end
|
109
|
+
|
119
110
|
def download(uri, file_name)
|
120
111
|
begin
|
121
|
-
@token = @token.refresh!
|
122
|
-
File.open(file_name, "w+b") do |file|
|
123
|
-
|
112
|
+
@token = @token.refresh! if @token.expired?
|
113
|
+
::File.open(file_name, "w+b") do |file|
|
114
|
+
full_uri = uri.start_with?(@cloud_url) ? uri : @cloud_url + uri
|
115
|
+
resp = @token.get(full_uri)
|
124
116
|
file.write(resp.body)
|
125
117
|
end
|
126
118
|
rescue => e
|
@@ -131,7 +123,7 @@ class Client
|
|
131
123
|
|
132
124
|
# Resources
|
133
125
|
|
134
|
-
|
126
|
+
# public read-only
|
135
127
|
|
136
128
|
def info
|
137
129
|
TestdroidAPI::CloudResource.new("/#{API_VERSION}/info", self, "info")
|
@@ -145,7 +137,7 @@ class Client
|
|
145
137
|
TestdroidAPI::LabelGroups.new("/#{API_VERSION}/label-groups", self)
|
146
138
|
end
|
147
139
|
|
148
|
-
|
140
|
+
# user read-write
|
149
141
|
|
150
142
|
def me
|
151
143
|
TestdroidAPI::User.new("/#{API_VERSION}/me", self).load
|
@@ -159,7 +151,7 @@ class Client
|
|
159
151
|
TestdroidAPI::DeviceSessionConnections.new("/#{API_VERSION}/device-session-connections", self)
|
160
152
|
end
|
161
153
|
|
162
|
-
|
154
|
+
# admin only
|
163
155
|
|
164
156
|
def admin
|
165
157
|
TestdroidAPI::Admin.new("/#{API_VERSION}/admin", self)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module TestdroidAPI
|
2
2
|
class CloudListResource
|
3
3
|
|
4
|
-
def initialize(uri, client, instance_class=nil)
|
4
|
+
def initialize(uri, client, instance_class = nil)
|
5
5
|
@uri, @client = uri, client
|
6
6
|
resource_name = self.class.name.split('::')[-1]
|
7
|
-
@instance_class = TestdroidAPI.const_get(
|
8
|
-
@list_key, @instance_id_key = resource_name.gsub!(/\b\w/) {
|
7
|
+
@instance_class = TestdroidAPI.const_get(instance_class.nil? ? resource_name.chop : instance_class)
|
8
|
+
@list_key, @instance_id_key = resource_name.gsub!(/\b\w/) {$&.downcase}, 'id'
|
9
9
|
end
|
10
10
|
|
11
11
|
def get(resource_id)
|
@@ -13,15 +13,13 @@ module TestdroidAPI
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def total
|
16
|
-
|
17
16
|
@client.get(@uri)['total']
|
18
17
|
end
|
19
18
|
|
20
|
-
def create(params=
|
19
|
+
def create(params = {})
|
21
20
|
raise "Can't create a resource without a REST Client" unless @client
|
22
21
|
response = @client.post @uri, params
|
23
|
-
@instance_class.new "#{@uri}/#{response[@instance_id_key]}", @client,
|
24
|
-
response
|
22
|
+
@instance_class.new "#{@uri}/#{response[@instance_id_key]}", @client, response
|
25
23
|
end
|
26
24
|
|
27
25
|
def list_all()
|
@@ -29,8 +27,8 @@ module TestdroidAPI
|
|
29
27
|
|
30
28
|
response = @client.get(@uri, {:limit => 0})
|
31
29
|
|
30
|
+
class_list = []
|
32
31
|
if response['data'].is_a?(Array)
|
33
|
-
class_list = []
|
34
32
|
instance_uri = @uri
|
35
33
|
response['data'].each do |val|
|
36
34
|
class_list << @instance_class.new("#{instance_uri}/#{val[@instance_id_key]}", @client, val)
|
@@ -39,15 +37,13 @@ module TestdroidAPI
|
|
39
37
|
class_list
|
40
38
|
end
|
41
39
|
|
42
|
-
def list(params={}, full_uri=false)
|
40
|
+
def list(params = {}, full_uri = false)
|
43
41
|
raise "Can't get a resource list without a REST Client" unless @client
|
44
42
|
@uri = full_uri ? @uri.split(@client.instance_variable_get(:@cloud_url))[1] : @uri
|
45
|
-
|
46
43
|
response = @client.get(@uri, params)
|
47
|
-
|
44
|
+
class_list = []
|
48
45
|
if response['data'].is_a?(Array)
|
49
46
|
client = @client
|
50
|
-
class_list = []
|
51
47
|
list_class = self.class
|
52
48
|
instance_uri = full_uri ? @uri.split('?')[0] : @uri
|
53
49
|
response['data'].each do |val|
|
@@ -59,9 +55,9 @@ module TestdroidAPI
|
|
59
55
|
self;
|
60
56
|
end
|
61
57
|
|
62
|
-
eigenclass.send :define_method, :offset, &lambda {
|
63
|
-
eigenclass.send :define_method, :limit, &lambda {
|
64
|
-
eigenclass.send :define_method, :total, &lambda {
|
58
|
+
eigenclass.send :define_method, :offset, &lambda {response['offset']}
|
59
|
+
eigenclass.send :define_method, :limit, &lambda {response['limit']}
|
60
|
+
eigenclass.send :define_method, :total, &lambda {response['total']}
|
65
61
|
eigenclass.send :define_method, :next_page, &lambda {
|
66
62
|
if response['next']
|
67
63
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module TestdroidAPI
|
2
2
|
class CloudResource
|
3
|
-
def initialize(uri, client, resource_name=nil, params= {})
|
3
|
+
def initialize(uri, client, resource_name = nil, params = {})
|
4
4
|
|
5
5
|
@uri, @client, @resource_name = uri, client, resource_name
|
6
6
|
set_up_properties_from(params)
|
@@ -18,7 +18,7 @@ module TestdroidAPI
|
|
18
18
|
new_class = resource_class.new(uri, @client)
|
19
19
|
instance_variable_set("@#{item}", new_class)
|
20
20
|
end
|
21
|
-
self.class.instance_eval {
|
21
|
+
self.class.instance_eval {attr_reader *items}
|
22
22
|
end
|
23
23
|
|
24
24
|
def method_missing(method, *args)
|
@@ -42,7 +42,7 @@ module TestdroidAPI
|
|
42
42
|
property = snake_case_it p
|
43
43
|
|
44
44
|
unless ['uri', 'client', 'updated'].include? property
|
45
|
-
eigenclass.send :define_method, property.to_sym, &lambda {
|
45
|
+
eigenclass.send :define_method, property.to_sym, &lambda {v}
|
46
46
|
end
|
47
47
|
end
|
48
48
|
@updated = !hash.keys.empty?
|
@@ -57,7 +57,7 @@ module TestdroidAPI
|
|
57
57
|
|
58
58
|
alias_method :load, :refresh
|
59
59
|
|
60
|
-
def download_file(file_resource_name, target_file_name=nil)
|
60
|
+
def download_file(file_resource_name, target_file_name = nil)
|
61
61
|
raise "Can't refresh a resource without a REST Client" unless @client
|
62
62
|
target_file_name = file_resource_name unless target_file_name
|
63
63
|
@client.download("#{@uri}/#{file_resource_name}", target_file_name)
|
@@ -65,7 +65,7 @@ module TestdroidAPI
|
|
65
65
|
|
66
66
|
def camel_case_it(something)
|
67
67
|
if something.is_a? Hash
|
68
|
-
Hash[*something.to_a.map {
|
68
|
+
Hash[*something.to_a.map {|a| [camel_case_it(a[0]).to_sym, a[1]]}.flatten]
|
69
69
|
else
|
70
70
|
something.to_s.split('_').map do |s|
|
71
71
|
[s[0, 1].capitalize, s[1..-1]].join
|
@@ -75,9 +75,9 @@ module TestdroidAPI
|
|
75
75
|
|
76
76
|
def snake_case_it(something)
|
77
77
|
if something.is_a? Hash
|
78
|
-
Hash[*something.to_a.map {
|
78
|
+
Hash[*something.to_a.map {|pair| [snake_case_it(pair[0]).to_sym, pair[1]]}.flatten]
|
79
79
|
else
|
80
|
-
something.to_s.gsub(/[A-Z][a-z]*/) {
|
80
|
+
something.to_s.gsub(/[A-Z][a-z]*/) {|s| "_#{s.downcase}"}.gsub(/^_/, '')
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -2,9 +2,10 @@ module TestdroidAPI
|
|
2
2
|
class DeviceGroups < CloudListResource
|
3
3
|
end
|
4
4
|
class DeviceGroup < CloudResource
|
5
|
-
def initialize(uri, client, params= {})
|
5
|
+
def initialize(uri, client, params = {})
|
6
6
|
super uri, client, "deviceGroup", params
|
7
7
|
@uri, @client = uri, client
|
8
|
+
sub_items :devices
|
8
9
|
end
|
9
10
|
|
10
11
|
end
|
@@ -2,7 +2,7 @@ module TestdroidAPI
|
|
2
2
|
class DeviceSessionConnections < CloudListResource
|
3
3
|
end
|
4
4
|
class DeviceSessionConnection < CloudResource
|
5
|
-
def initialize(uri, client, params= {})
|
5
|
+
def initialize(uri, client, params = {})
|
6
6
|
super uri, client, "DeviceSessionConnection", params
|
7
7
|
@uri, @client = uri, client
|
8
8
|
end
|
@@ -2,13 +2,22 @@ module TestdroidAPI
|
|
2
2
|
class DeviceSessions < CloudListResource
|
3
3
|
end
|
4
4
|
class DeviceSession < CloudResource
|
5
|
-
def initialize(uri, client, params= {})
|
5
|
+
def initialize(uri, client, params = {})
|
6
6
|
super uri, client, "deviceSession", params
|
7
7
|
@uri, @client = uri, client
|
8
8
|
end
|
9
9
|
|
10
10
|
def release
|
11
|
-
|
11
|
+
@client.post("#{@uri}/release", params = {})
|
12
12
|
end
|
13
|
+
|
14
|
+
def download_all_files(path)
|
15
|
+
Dir.mkdir(path) unless Dir.exist?(path)
|
16
|
+
files = @client.get("#{@uri}/output-file-set/files")
|
17
|
+
files['data'].each do |file|
|
18
|
+
@client.download(file['directUrl'], ::File.join(path, "#{file['id']}-#{file['name']}"))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
13
22
|
end
|
14
23
|
end
|
data/lib/testdroid_api/files.rb
CHANGED
@@ -1,59 +1,20 @@
|
|
1
1
|
module TestdroidAPI
|
2
|
-
class Files <
|
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)
|
2
|
+
class Files < CloudListResource
|
14
3
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def uploadData(filename)
|
19
|
-
if !File.exist?(filename)
|
4
|
+
def upload(filename)
|
5
|
+
unless ::File.exist?(filename)
|
20
6
|
@client.logger.error("Invalid filename")
|
21
7
|
return
|
22
8
|
end
|
23
|
-
|
24
|
-
|
25
|
-
Data.new(nil, nil, reply)
|
9
|
+
file = @client.upload("#{@uri}", filename)
|
10
|
+
File.new("#{@uri}/#{file['id']}", @client, file)
|
26
11
|
end
|
27
12
|
|
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
13
|
end
|
45
|
-
class
|
46
|
-
def initialize(uri, client, params= {})
|
47
|
-
super uri, client, "
|
14
|
+
class File < CloudResource
|
15
|
+
def initialize(uri, client, params = {})
|
16
|
+
super uri, client, "file", params
|
48
17
|
@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
18
|
end
|
58
19
|
end
|
59
20
|
end
|
@@ -2,7 +2,7 @@ module TestdroidAPI
|
|
2
2
|
class LabelGroups < CloudListResource
|
3
3
|
end
|
4
4
|
class LabelGroup < CloudResource
|
5
|
-
def initialize(uri, client, params= {})
|
5
|
+
def initialize(uri, client, params = {})
|
6
6
|
super uri, client, "labelGroup", params
|
7
7
|
@uri, @client = uri, client
|
8
8
|
sub_items :labels
|