testdroid-api-client 0.4.1 → 0.6.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/Gemfile.lock +40 -44
- data/README.md +8 -2
- data/lib/testdroid-api-client.rb +3 -2
- data/lib/testdroid_api/apikey_client.rb +43 -2
- data/lib/testdroid_api/files.rb +44 -2
- data/sample/sample.rb +1 -3
- data/spec/client_spec.rb +1 -1
- data/spec/device_groups_spec.rb +1 -1
- data/spec/files_spec.rb +13 -2
- data/spec/fixtures/app.apk +0 -0
- data/spec/fixtures/cassettes/device_groups_authorize.json +1 -1
- data/spec/fixtures/cassettes/device_groups_create.json +1 -1
- data/spec/fixtures/cassettes/device_groups_delete.json +1 -1
- data/spec/fixtures/cassettes/device_groups_get_all.json +1 -1
- data/spec/fixtures/cassettes/device_groups_get_one.json +1 -1
- data/spec/fixtures/cassettes/files_authorize.json +1 -1
- data/spec/fixtures/cassettes/files_delete.json +1 -1
- data/spec/fixtures/cassettes/files_get_all.json +1 -1
- data/spec/fixtures/cassettes/files_get_one.json +1 -1
- data/spec/fixtures/cassettes/files_upload.json +1 -1
- data/spec/fixtures/cassettes/files_upload_with_wait.json +1 -0
- data/spec/fixtures/cassettes/label_groups_authorize.json +1 -1
- data/spec/fixtures/cassettes/label_groups_create.json +1 -1
- data/spec/fixtures/cassettes/label_groups_delete.json +1 -1
- data/spec/fixtures/cassettes/label_groups_get_all.json +1 -1
- data/spec/fixtures/cassettes/label_groups_get_labels.json +1 -1
- data/spec/fixtures/cassettes/label_groups_get_one.json +1 -1
- data/spec/fixtures/cassettes/projects_authorize.json +1 -1
- data/spec/fixtures/cassettes/projects_create.json +1 -1
- data/spec/fixtures/cassettes/projects_delete.json +1 -1
- data/spec/fixtures/cassettes/projects_get_all.json +1 -1
- data/spec/fixtures/cassettes/projects_get_one.json +1 -1
- data/spec/fixtures/cassettes/runs_abort_run.json +1 -1
- data/spec/fixtures/cassettes/runs_authorize.json +1 -1
- data/spec/fixtures/cassettes/runs_get_project_runs.json +1 -1
- data/spec/fixtures/cassettes/runs_start_run.json +1 -1
- data/spec/fixtures/data.txt +1 -0
- data/spec/fixtures/data2.txt +1 -0
- data/spec/fixtures/test.apk +0 -0
- data/spec/label_groups_spec.rb +2 -2
- data/spec/projects_spec.rb +1 -1
- data/spec/runs_spec.rb +6 -4
- data/spec/spec_helper.rb +2 -2
- data/testdroid-api-client.gemspec +2 -2
- metadata +8 -5
- data/lib/testdroid_api/client.rb +0 -161
- data/spec/fixtures/apk.apk +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Empty file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Some test data
|
|
Binary file
|
data/spec/label_groups_spec.rb
CHANGED
|
@@ -18,7 +18,7 @@ describe TestdroidAPI::LabelGroups do
|
|
|
18
18
|
|
|
19
19
|
it 'create label group' do
|
|
20
20
|
VCR.use_cassette(File.basename(__FILE__).split('_spec')[0] + '_create') do
|
|
21
|
-
label_group = client_local_host.label_groups.create({:
|
|
21
|
+
label_group = client_local_host.label_groups.create({:displayName => 'Empty', :name => 'empty'})
|
|
22
22
|
LG_ID = label_group.id
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -27,7 +27,7 @@ describe TestdroidAPI::LabelGroups do
|
|
|
27
27
|
VCR.use_cassette(File.basename(__FILE__).split('_spec')[0] + '_get_one') do
|
|
28
28
|
label_group = client_local_host.label_groups.get(LG_ID)
|
|
29
29
|
expect(label_group.id).to be(LG_ID)
|
|
30
|
-
expect(label_group.display_name).to eq(
|
|
30
|
+
expect(label_group.display_name).to eq('Empty')
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
data/spec/projects_spec.rb
CHANGED
|
@@ -11,7 +11,7 @@ describe TestdroidAPI::Project do
|
|
|
11
11
|
|
|
12
12
|
it 'create project' do
|
|
13
13
|
VCR.use_cassette(File.basename(__FILE__).split('_spec')[0] + '_create') do
|
|
14
|
-
project = @user.projects.create({:
|
|
14
|
+
project = @user.projects.create({:name => 'My Project'})
|
|
15
15
|
expect(project.name).to eq 'My Project'
|
|
16
16
|
P_ID = project.id
|
|
17
17
|
end
|
data/spec/runs_spec.rb
CHANGED
|
@@ -12,11 +12,13 @@ describe TestdroidAPI::Project do
|
|
|
12
12
|
|
|
13
13
|
it 'start test run' do
|
|
14
14
|
VCR.use_cassette(File.basename(__FILE__).split('_spec')[0] + '_start_run') do
|
|
15
|
-
framework_id = @user.available_frameworks.list({:filter => "s_osType_eq_ANDROID;s_name_like_%
|
|
16
|
-
app_file_id = @user.files.upload(File.join(File.dirname(__FILE__), 'fixtures', '
|
|
15
|
+
framework_id = @user.available_frameworks.list({:filter => "s_osType_eq_ANDROID;s_name_like_%Android Instrumentation"})[0].id
|
|
16
|
+
app_file_id = @user.files.upload(File.join(File.dirname(__FILE__), 'fixtures', 'app.apk')).id
|
|
17
|
+
test_file_id = @user.files.upload(File.join(File.dirname(__FILE__), 'fixtures', 'test.apk')).id
|
|
17
18
|
|
|
18
19
|
test_run = @user.runs.create("{\"osType\": \"ANDROID\", \"projectName\": \"My new Project\",
|
|
19
|
-
\"frameworkId\":#{framework_id}, \"files\": [{\"id\": #{app_file_id}, \"action\": \"INSTALL\" }
|
|
20
|
+
\"frameworkId\":#{framework_id}, \"files\": [{\"id\": #{app_file_id}, \"action\": \"INSTALL\" },
|
|
21
|
+
{\"id\": #{test_file_id}, \"action\": \"RUN_TEST\" }]}")
|
|
20
22
|
|
|
21
23
|
P_ID = test_run.project_id
|
|
22
24
|
TR_ID = test_run.id
|
|
@@ -26,7 +28,7 @@ describe TestdroidAPI::Project do
|
|
|
26
28
|
it 'get project test runs' do
|
|
27
29
|
VCR.use_cassette(File.basename(__FILE__).split('_spec')[0] + '_get_project_runs') do
|
|
28
30
|
test_runs = @user.projects.get(P_ID).runs
|
|
29
|
-
|
|
31
|
+
expect(test_runs.total).to satisfy {|n| n > 0}
|
|
30
32
|
end
|
|
31
33
|
end
|
|
32
34
|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -20,14 +20,14 @@ end
|
|
|
20
20
|
|
|
21
21
|
def client
|
|
22
22
|
@client ||= begin
|
|
23
|
-
client =
|
|
23
|
+
client = ApikeyClient.new('API_KEY')
|
|
24
24
|
rescue Exception => e
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def client_local_host(local_cloud='http://localhost/testdroid-cloud')
|
|
29
29
|
@client_local_host ||= begin
|
|
30
|
-
client_local_host =
|
|
30
|
+
client_local_host = ApikeyClient.new('API_KEY', local_cloud)
|
|
31
31
|
rescue Exception => e
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = "testdroid-api-client"
|
|
3
|
-
s.version = "0.
|
|
3
|
+
s.version = "0.6.0"
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
7
|
-
s.authors = ["Sakari Rautiainen", "Marek Sierociński"]
|
|
7
|
+
s.authors = ["Sakari Rautiainen", "Marek Sierociński", "Michał Szpruta"]
|
|
8
8
|
s.date = %q{2017-04-26}
|
|
9
9
|
s.description = %q{Ruby client for testdroid api v2}
|
|
10
10
|
s.license = "MIT"
|
metadata
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: testdroid-api-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sakari Rautiainen
|
|
8
8
|
- Marek Sierociński
|
|
9
|
+
- Michał Szpruta
|
|
9
10
|
autorequire:
|
|
10
11
|
bindir: bin
|
|
11
12
|
cert_chain: []
|
|
@@ -191,7 +192,6 @@ files:
|
|
|
191
192
|
- lib/testdroid_api/admin_device_statuses.rb
|
|
192
193
|
- lib/testdroid_api/admin_devices.rb
|
|
193
194
|
- lib/testdroid_api/apikey_client.rb
|
|
194
|
-
- lib/testdroid_api/client.rb
|
|
195
195
|
- lib/testdroid_api/cloud_list_resource.rb
|
|
196
196
|
- lib/testdroid_api/cloud_resource.rb
|
|
197
197
|
- lib/testdroid_api/device_groups.rb
|
|
@@ -213,7 +213,7 @@ files:
|
|
|
213
213
|
- spec/client_spec.rb
|
|
214
214
|
- spec/device_groups_spec.rb
|
|
215
215
|
- spec/files_spec.rb
|
|
216
|
-
- spec/fixtures/
|
|
216
|
+
- spec/fixtures/app.apk
|
|
217
217
|
- spec/fixtures/cassettes/device_groups_authorize.json
|
|
218
218
|
- spec/fixtures/cassettes/device_groups_create.json
|
|
219
219
|
- spec/fixtures/cassettes/device_groups_delete.json
|
|
@@ -224,6 +224,7 @@ files:
|
|
|
224
224
|
- spec/fixtures/cassettes/files_get_all.json
|
|
225
225
|
- spec/fixtures/cassettes/files_get_one.json
|
|
226
226
|
- spec/fixtures/cassettes/files_upload.json
|
|
227
|
+
- spec/fixtures/cassettes/files_upload_with_wait.json
|
|
227
228
|
- spec/fixtures/cassettes/label_groups_authorize.json
|
|
228
229
|
- spec/fixtures/cassettes/label_groups_create.json
|
|
229
230
|
- spec/fixtures/cassettes/label_groups_delete.json
|
|
@@ -239,6 +240,9 @@ files:
|
|
|
239
240
|
- spec/fixtures/cassettes/runs_authorize.json
|
|
240
241
|
- spec/fixtures/cassettes/runs_get_project_runs.json
|
|
241
242
|
- spec/fixtures/cassettes/runs_start_run.json
|
|
243
|
+
- spec/fixtures/data.txt
|
|
244
|
+
- spec/fixtures/data2.txt
|
|
245
|
+
- spec/fixtures/test.apk
|
|
242
246
|
- spec/label_groups_spec.rb
|
|
243
247
|
- spec/projects_spec.rb
|
|
244
248
|
- spec/runs_spec.rb
|
|
@@ -263,8 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
263
267
|
- !ruby/object:Gem::Version
|
|
264
268
|
version: '0'
|
|
265
269
|
requirements: []
|
|
266
|
-
|
|
267
|
-
rubygems_version: 2.7.7
|
|
270
|
+
rubygems_version: 3.3.5
|
|
268
271
|
signing_key:
|
|
269
272
|
specification_version: 3
|
|
270
273
|
summary: Testdroid API Client!
|
data/lib/testdroid_api/client.rb
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
module TestdroidAPI
|
|
2
|
-
|
|
3
|
-
class Client
|
|
4
|
-
attr_reader :config
|
|
5
|
-
attr_accessor :logger
|
|
6
|
-
attr_reader :token
|
|
7
|
-
|
|
8
|
-
API_VERSION = 'api/v2'
|
|
9
|
-
CLOUD_ENDPOINT = 'https://cloud.bitbar.com'
|
|
10
|
-
|
|
11
|
-
def initialize(username, password, cloud_url = CLOUD_ENDPOINT, logger = nil)
|
|
12
|
-
# Instance variables
|
|
13
|
-
@username = username
|
|
14
|
-
@password = password
|
|
15
|
-
@cloud_url = cloud_url
|
|
16
|
-
@logger = logger
|
|
17
|
-
|
|
18
|
-
if @logger.nil?
|
|
19
|
-
@logger = Logger.new(STDOUT)
|
|
20
|
-
@logger.info("Logger is not defined => output to STDOUT")
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
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
|
|
29
|
-
faraday.response :logger, @logger
|
|
30
|
-
faraday.adapter Faraday.default_adapter
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
@token = @client.password.get_token(@username, @password)
|
|
34
|
-
|
|
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
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
@cloud_user
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def mime_for(path)
|
|
44
|
-
mime = MIME::Types.type_for path
|
|
45
|
-
mime.empty? ? 'text/plain' : mime[0].content_type
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def upload(uri, filename)
|
|
49
|
-
begin
|
|
50
|
-
@token = @token.refresh! if @token.expired?
|
|
51
|
-
connection = @token.client.connection
|
|
52
|
-
payload = {:file => Faraday::UploadIO.new(filename, mime_for(filename))}
|
|
53
|
-
response = connection.post(@cloud_url + "#{uri}", payload, @token.headers)
|
|
54
|
-
rescue => e
|
|
55
|
-
@logger.error e
|
|
56
|
-
return nil
|
|
57
|
-
end
|
|
58
|
-
JSON.parse(response.body)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def post(uri, params = {})
|
|
62
|
-
|
|
63
|
-
@token = @token.refresh! if @token.expired?
|
|
64
|
-
|
|
65
|
-
begin
|
|
66
|
-
resp = @token.post("#{@cloud_url}#{uri}", params)
|
|
67
|
-
rescue => e
|
|
68
|
-
@logger.error "Failed to post resource #{uri} #{e}"
|
|
69
|
-
return nil
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
if resp.body.nil? || resp.body.length == 0
|
|
73
|
-
return nil
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
JSON.parse(resp.body)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def get(uri, params = {})
|
|
80
|
-
|
|
81
|
-
@token = @token.refresh! if @token.expired?
|
|
82
|
-
|
|
83
|
-
begin
|
|
84
|
-
resp = @token.get(@cloud_url + "#{uri}", :params => params)
|
|
85
|
-
rescue => e
|
|
86
|
-
@logger.error "Failed to get resource #{uri} #{e}"
|
|
87
|
-
return nil
|
|
88
|
-
end
|
|
89
|
-
JSON.parse(resp.body)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def delete(uri)
|
|
93
|
-
|
|
94
|
-
@token = @token.refresh! if @token.expired?
|
|
95
|
-
|
|
96
|
-
begin
|
|
97
|
-
resp = @token.delete(@cloud_url + "#{uri}")
|
|
98
|
-
rescue => e
|
|
99
|
-
@logger.error "Failed to delete resource #{uri} #{e}"
|
|
100
|
-
return nil
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
if resp.status != 204
|
|
104
|
-
@logger.error "Failed to delete resource #{uri} #{e}"
|
|
105
|
-
else
|
|
106
|
-
@logger.info "response: #{resp.status}"
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def download(uri, file_name)
|
|
111
|
-
begin
|
|
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)
|
|
116
|
-
file.write(resp.body)
|
|
117
|
-
end
|
|
118
|
-
rescue => e
|
|
119
|
-
@logger.error "Failed to get resource #{uri} #{e}"
|
|
120
|
-
return nil
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# Resources
|
|
125
|
-
|
|
126
|
-
# public read-only
|
|
127
|
-
|
|
128
|
-
def info
|
|
129
|
-
TestdroidAPI::CloudResource.new("/#{API_VERSION}/info", self, "info")
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
def devices
|
|
133
|
-
TestdroidAPI::Devices.new("/#{API_VERSION}/devices", self)
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def label_groups
|
|
137
|
-
TestdroidAPI::LabelGroups.new("/#{API_VERSION}/label-groups", self)
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
# user read-write
|
|
141
|
-
|
|
142
|
-
def me
|
|
143
|
-
TestdroidAPI::User.new("/#{API_VERSION}/me", self).load
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
def properties
|
|
147
|
-
TestdroidAPI::Properties.new("/#{API_VERSION}/properties", self)
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
def device_session_connections
|
|
151
|
-
TestdroidAPI::DeviceSessionConnections.new("/#{API_VERSION}/device-session-connections", self)
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
# admin only
|
|
155
|
-
|
|
156
|
-
def admin
|
|
157
|
-
TestdroidAPI::Admin.new("/#{API_VERSION}/admin", self)
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
end
|
|
161
|
-
end
|
data/spec/fixtures/apk.apk
DELETED
|
Binary file
|