testdroid-api 1.0.1

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.
@@ -0,0 +1 @@
1
+ asddskflsvnlnld sn
@@ -0,0 +1,11 @@
1
+ {
2
+ "id": 1000,
3
+ "deviceId": 216252,
4
+ "logURI": null,
5
+ "customerFailureMessage": "Failed to download test fixtures from Testdroid server",
6
+ "deviceName": "Samsung Galaxy Nexus 4.0.4",
7
+ "junitURI": null,
8
+ "screenshotsURI": null,
9
+ "groupState": "FINISHED",
10
+ "finished": true
11
+ }
@@ -0,0 +1,35 @@
1
+ [
2
+ {
3
+ "id": 29515106,
4
+ "deviceId": 217558,
5
+ "logURI": null,
6
+ "customerFailureMessage": "Oops, something went wrong",
7
+ "deviceName": "HTC Google Nexus One",
8
+ "junitURI": null,
9
+ "screenshotsURI": null,
10
+ "groupState": "FINISHED",
11
+ "finished": true
12
+ },
13
+ {
14
+ "id": 29515104,
15
+ "deviceId": 173661,
16
+ "logURI": null,
17
+ "customerFailureMessage": "Oops, something went wrong",
18
+ "deviceName": "HTC Wildfire",
19
+ "junitURI": null,
20
+ "screenshotsURI": null,
21
+ "groupState": "FINISHED",
22
+ "finished": true
23
+ },
24
+ {
25
+ "id": 29515105,
26
+ "deviceId": 216252,
27
+ "logURI": null,
28
+ "customerFailureMessage": "Failed to download test fixtures from Testdroid server",
29
+ "deviceName": "Samsung Galaxy Nexus 4.0.4",
30
+ "junitURI": null,
31
+ "screenshotsURI": null,
32
+ "groupState": "FINISHED",
33
+ "finished": true
34
+ }
35
+ ]
@@ -0,0 +1,34 @@
1
+ [
2
+ {
3
+ "id": 112660,
4
+ "name": "2012-06-19_12:21:56_624c3f601b",
5
+ "displayName": "several",
6
+ "deviceCount": 3,
7
+ "creditsPrice" :10,
8
+ "coverage": 0
9
+ },
10
+ {
11
+ "id": 108590,
12
+ "name": "2012-06-14_17:45:02_337f6a5023",
13
+ "displayName": "all devices",
14
+ "deviceCount": 26,
15
+ "creditsPrice": 0,
16
+ "coverage": 0
17
+ },
18
+ {
19
+ "id": 108591,
20
+ "name": "2012-06-14_17:45:02_337f6a5023",
21
+ "displayName": "Test devices",
22
+ "deviceCount": 26,
23
+ "creditsPrice": 0,
24
+ "coverage": 0
25
+ },
26
+ {
27
+ "id": 108595,
28
+ "name": "2012-06-14_17:45:02_337f6a5023",
29
+ "displayName": "Smoke devices",
30
+ "deviceCount": 26,
31
+ "creditsPrice": 0,
32
+ "coverage": 0
33
+ }
34
+ ]
@@ -0,0 +1,5 @@
1
+ {
2
+ "displayName" : "Renamed",
3
+ "groupState" : "FINISHED",
4
+ "id" : 10176
5
+ }
@@ -0,0 +1,24 @@
1
+ <testsuites>
2
+ <testsuite name="Customer Demographics Tests" tests="9" failures="0" timestamp="2012-08-23T14:40:44.874443-05:00">
3
+ <testcase name="Insert First Name" classname="CustomerDemographicsPKG.Name"/>
4
+ <testcase name="Insert Last Name" classname="CustomerDemographicsPKG.Name"/>
5
+ <testcase name="Change First Name" classname="CustomerDemographicsPKG.Name"/>
6
+ <testcase name="Change Last Name" classname="CustomerDemographicsPKG.Name"/>
7
+ <testcase name="Delete First Name" classname="CustomerDemographicsPKG.Name"/>
8
+ <testcase name="Delete Last Name" classname="CustomerDemographicsPKG.Name"/>
9
+ <testcase name="Insert DOB" classname="CustomerDemographicsPKG.Misc"/>
10
+ <testcase name="Update DOB" classname="CustomerDemographicsPKG.Misc"/>
11
+ <testcase name="Delete DOB" classname="CustomerDemographicsPKG.Misc"/>
12
+ </testsuite>
13
+ <testsuite name="Customer Contact Tests" tests="4" failures="1" timestamp="2012-08-23T14:40:44.874443-05:00">
14
+ <testcase name="Insert Street" classname="CustomerContact.Address"/>
15
+ <testcase name="Insert City" classname="CustomerContact.Address"/>
16
+ <testcase name="Insert State" classname="CustomerContact.Address"/>
17
+ <testcase name="Zip" classname="CustomerContact.Address">
18
+ <error message="Zip code out of range">Zip code 139819 is not in range of valid zip codes.</error>
19
+ </testcase>
20
+ <testcase name="Insert Home Phone" classname="CustomerContact.Phone"/>
21
+ <testcase name="Insert Cell Phone" classname="CustomerContact.Phone"/>
22
+ <testcase name="Insert Business Phone" classname="CustomerContact.Phone"/>
23
+ </testsuite>
24
+ </testsuites>
Binary file
@@ -0,0 +1 @@
1
+ asdfsjsndfjkndjnfds
Binary file
@@ -0,0 +1,7 @@
1
+ {
2
+ "description" : "New project",
3
+ "id" : 232341,
4
+ "name" : "New project name",
5
+ "appFile": "",
6
+ "testFile": ""
7
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "id":10176,
3
+ "groupState":"WAITING",
4
+ "displayName":"Test Run 2"
5
+ }
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "description" : "Project description",
4
+ "id" : 232340,
5
+ "name" : "Project 1",
6
+ "appFile": {
7
+ "originalName": "application.apk",
8
+ "uploadTime": 1344594363000
9
+ },
10
+ "testFile": {
11
+ "originalName": "instrumentation.apk",
12
+ "uploadTime": 1344594378000
13
+ }
14
+ },
15
+ {
16
+ "description" : "Project 2 desc.",
17
+ "id" : 232341,
18
+ "name" : "Project 2",
19
+ "appFile": null,
20
+ "testFile": null
21
+ }
22
+ ]
@@ -0,0 +1,13 @@
1
+ [
2
+ {
3
+ "displayName" : "Test Run 1",
4
+ "groupState" : "FINISHED",
5
+ "id" : 175170
6
+ },
7
+ {
8
+ "displayName" : "Test Run 2",
9
+ "groupState" : "FINISHED",
10
+ "id" : 175171
11
+ }
12
+ ]
13
+
@@ -0,0 +1,11 @@
1
+ {
2
+ "id": 1000,
3
+ "deviceId": 216252,
4
+ "logURI": null,
5
+ "customerFailureMessage": "Failed to download test fixtures from Testdroid server",
6
+ "deviceName": "Samsung Galaxy Nexus 4.0.4",
7
+ "junitURI": null,
8
+ "screenshotsURI": null,
9
+ "groupState": "WAITING",
10
+ "finished": false
11
+ }
@@ -0,0 +1,167 @@
1
+ require 'spec_helper'
2
+
3
+ describe TestdroidApi::Client::Project do
4
+ let(:auth_url) {"http://users.testdroid.com/api/v1/authorize"}
5
+ let(:client) { TestdroidApi::Client.new("username", "password") }
6
+
7
+ let(:project_file) { File.new(File.dirname(__FILE__) + "/fixtures/new_project.json").read }
8
+ let(:project) { described_class.new(client, JSON.parse(project_file))}
9
+
10
+ before do
11
+ stub_request(:post, auth_url).
12
+ to_return(:status => 200, :body => {"secretApiKey" => "1"}.to_json, :headers => {})
13
+ client.authenticate!
14
+ end
15
+
16
+ context 'when authenticated' do
17
+ describe '#delete' do
18
+ let(:url) {"https://cloud.testdroid.com/api/v1/projects/232341/delete"}
19
+ before do
20
+ stub_request(:post, url).
21
+ to_return(:status => 200, :body => {}.to_json, :headers => {})
22
+ end
23
+ it 'sends the right request' do
24
+ project.delete!
25
+
26
+ a_request(:post, url).should have_been_made
27
+ end
28
+ end
29
+
30
+ describe '#upload_app_file' do
31
+ let(:url) {"https://cloud.testdroid.com/api/v1/projects/232341/apks/application"}
32
+ let(:apk_file_path) {File.dirname(__FILE__) + '/fixtures/app.apk'}
33
+
34
+ before do
35
+ stub_request(:post, url).
36
+ to_return(:status => 200, :body => {}.to_json, :headers => {})
37
+ end
38
+
39
+ it 'sends the right request' do
40
+ project.upload_app_file(apk_file_path)
41
+
42
+ a_request(:post, url).should have_been_made
43
+ end
44
+
45
+ it 'ads Md5 to headers' do
46
+ project.upload_app_file(apk_file_path)
47
+
48
+ a_request(:post, url).with{ |request| request.headers.has_key? "X-Testdroid-Md5" }.
49
+ should have_been_made
50
+ end
51
+ end
52
+
53
+ describe '#upload_test_file' do
54
+ let(:url) {"https://cloud.testdroid.com/api/v1/projects/232341/apks/instrumentation"}
55
+ let(:apk_file_path) {File.dirname(__FILE__) + '/fixtures/app.apk'}
56
+
57
+ before do
58
+ stub_request(:post, url).
59
+ to_return(:status => 200, :body => {}.to_json, :headers => {})
60
+ end
61
+
62
+ it 'sends the right request' do
63
+ project.upload_test_file(apk_file_path)
64
+
65
+ a_request(:post, url).
66
+ should have_been_made
67
+ end
68
+ it 'ads Md5 to headers' do
69
+ project.upload_test_file(apk_file_path)
70
+
71
+ a_request(:post, url).with{ |request| request.headers.has_key? "X-Testdroid-Md5" }.
72
+ should have_been_made
73
+ end
74
+ it 'sends the file' do
75
+ project.upload_test_file(apk_file_path)
76
+
77
+ a_request(:post, url).with(:body => /filename="app.apk"/).
78
+ should have_been_made
79
+ end
80
+ end
81
+
82
+ describe '#create_test_run' do
83
+ let(:url) { "https://cloud.testdroid.com/api/v1/projects/232341/run" }
84
+ let(:response_body) {File.new(File.dirname(__FILE__) + "/fixtures/new_run.json").read}
85
+ before do
86
+ stub_request(:post, url).
87
+ to_return(:status => 200, :body => JSON.parse(response_body).to_json, :headers => {})
88
+ end
89
+
90
+ it 'sends the right request' do
91
+ project.create_test_run
92
+
93
+ a_request(:post, url).should have_been_made
94
+ end
95
+
96
+ it 'creates new test run' do
97
+ project.create_test_run.should be_kind_of TestdroidApi::Client::Project::TestRun
98
+ end
99
+
100
+ it 'adds default params' do
101
+ project.create_test_run
102
+ a_request(:post, url).
103
+ with(:body => 'instatestMode=false&autoScreenshots=false&usedClusterId=all%20devices').should have_been_made
104
+ end
105
+
106
+ context 'with extra parameters' do
107
+ let(:device_group) {double(TestdroidApi::Client::DeviceGroup)}
108
+ before do
109
+ device_group.stub(:id).and_return(1)
110
+ end
111
+
112
+ it 'sets proper device group' do
113
+ project.create_test_run(device_group)
114
+
115
+ a_request(:post, url).
116
+ with(:body => 'instatestMode=false&autoScreenshots=false&usedClusterId=1').should have_been_made
117
+ end
118
+ it 'sets auto screen shots' do
119
+ project.create_test_run(device_group, false, true)
120
+
121
+ a_request(:post, url).
122
+ with(:body => 'instatestMode=false&autoScreenshots=true&usedClusterId=1').should have_been_made
123
+
124
+ end
125
+ it 'sets instatest mode' do
126
+ project.create_test_run(device_group, true, false)
127
+
128
+ a_request(:post, url).
129
+ with(:body => 'instatestMode=true&autoScreenshots=false&usedClusterId=1').should have_been_made
130
+ end
131
+ end
132
+ end
133
+
134
+ describe '#test_runs' do
135
+ let(:url) { "https://cloud.testdroid.com/api/v1/projects/232341/runs" }
136
+ let(:response_body) {File.new(File.dirname(__FILE__) + "/fixtures/test_runs.json").read}
137
+
138
+ before do
139
+ stub_request(:get, url).
140
+ to_return(:status => 200, :body => JSON.parse(response_body).to_json, :headers => {})
141
+
142
+ TestdroidApi::Client::Project::TestRun.stub(:new).and_return(true)
143
+ end
144
+
145
+ it 'sends the right request' do
146
+ project.test_runs
147
+
148
+ a_request(:get, url).should have_been_made
149
+ end
150
+ it 'returns array of test runs' do
151
+ project.test_runs.should == [true, true]
152
+ end
153
+ end
154
+
155
+ describe '#config' do
156
+ it 'is not implemented' do
157
+ expect {project.config}.to raise_error(NotImplementedError)
158
+ end
159
+ end
160
+
161
+ describe '#update_config' do
162
+ it 'is not implemented' do
163
+ expect {project.update_config({})}.to raise_error(NotImplementedError)
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,10 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter "spec/"
4
+ end
5
+
6
+ require 'testdroid-api'
7
+ require 'webmock/rspec'
8
+
9
+ include TestdroidApi
10
+
@@ -0,0 +1,159 @@
1
+ require 'spec_helper'
2
+ describe TestdroidApi::Client::Project::TestRun do
3
+ let(:auth_url) { "http://users.testdroid.com/api/v1/authorize" }
4
+ let(:project) { double(TestdroidApi::Client::Project) }
5
+ let(:client) { TestdroidApi::Client.new('username', 'password') }
6
+
7
+ before do
8
+ stub_request(:post, auth_url).
9
+ to_return(:status => 200, :body => {"secretApiKey" => "1"}.to_json, :headers => {})
10
+ client.authenticate!
11
+ project.stub(:id).and_return(1)
12
+ end
13
+
14
+ context 'when authenticated' do
15
+ let(:run_config) { JSON.parse(File.new(File.dirname(__FILE__) + "/fixtures/new_run.json").read)}
16
+ let(:test_run) { described_class.new(client, project, run_config) }
17
+
18
+ describe '#update!' do
19
+ let(:url) { "https://cloud.testdroid.com/api/v1/projects/1/runs/10176" }
20
+ let(:response_body) {File.new(File.dirname(__FILE__) + "/fixtures/finished_run.json").read}
21
+ before do
22
+ stub_request(:get, url).
23
+ to_return(:status => 200, :body => JSON.parse(response_body).to_json, :headers => {})
24
+ end
25
+
26
+ it 'sends the right request' do
27
+ test_run.update!
28
+
29
+ a_request(:get, url).
30
+ should have_been_made
31
+ end
32
+
33
+ it 'updates run state' do
34
+ test_run.update!
35
+ test_run.state.should == "FINISHED"
36
+ end
37
+
38
+ it 'updates run name' do
39
+ test_run.update!
40
+ test_run.name.should == "Renamed"
41
+ end
42
+ end
43
+
44
+ describe '#device_runs' do
45
+ let(:url) { "https://cloud.testdroid.com/api/v1/projects/1/runs/10176/device-runs" }
46
+ let(:response_body) {File.new(File.dirname(__FILE__) + "/fixtures/device_runs.json").read}
47
+
48
+ before do
49
+ stub_request(:get, url).
50
+ to_return(:status => 200, :body => JSON.parse(response_body).to_json, :headers => {})
51
+ end
52
+
53
+ it 'sends the right request' do
54
+ test_run.device_runs
55
+
56
+ a_request(:get, url).should have_been_made
57
+ end
58
+
59
+ it 'returns array of DeviceRuns' do
60
+ TestdroidApi::Client::Project::TestRun::DeviceRun.stub(:new).and_return(true)
61
+
62
+ test_run.device_runs.should == [true, true, true]
63
+ end
64
+ end
65
+
66
+ describe '#finished' do
67
+ let(:url) { "https://cloud.testdroid.com/api/v1/projects/1/runs/10176" }
68
+ let(:response_body) {File.new(File.dirname(__FILE__) + "/fixtures/finished_run.json").read}
69
+ before do
70
+ stub_request(:get, url).
71
+ to_return(:status => 200, :body => JSON.parse(response_body).to_json, :headers => {})
72
+ end
73
+
74
+ it 'returns false when run it not finished' do
75
+ test_run.should_not be_finished
76
+ end
77
+
78
+ it 'returns true when run is finished' do
79
+ test_run.update!
80
+ test_run.should be_finished
81
+ end
82
+ end
83
+
84
+ describe '#logs_zip' do
85
+ let(:url) { "https://cloud.testdroid.com/api/v1/projects/1/runs/10176/logs.zip" }
86
+ let(:response_body) {File.new(File.dirname(__FILE__) + "/fixtures/logs.zip")}
87
+ before do
88
+ stub_request(:get, url).
89
+ to_return(:status => 200, :body => response_body, :headers => {})
90
+ end
91
+
92
+ it 'sends the right request' do
93
+ test_run.logs_zip
94
+
95
+ a_request(:get, url).should have_been_made
96
+ end
97
+
98
+ it 'does not JSON parse response' do
99
+ client = double(client)
100
+ client.should_receive(:get_file).with(any_args)
101
+
102
+ run = TestdroidApi::Client::Project::TestRun.new(client, project, {})
103
+ run.logs_zip
104
+ end
105
+ end
106
+
107
+ describe '#screenshots_zip' do
108
+ let(:url) { "https://cloud.testdroid.com/api/v1/projects/1/runs/10176/screenshots.zip" }
109
+ let(:response_body) {File.new(File.dirname(__FILE__) + "/fixtures/logs.zip")}
110
+ before do
111
+ stub_request(:get, url).
112
+ to_return(:status => 200, :body => response_body, :headers => {})
113
+ end
114
+
115
+ it 'sends the right request' do
116
+ test_run.screenshots_zip
117
+
118
+ a_request(:get, url).should have_been_made
119
+ end
120
+
121
+ it 'does not JSON parse response' do
122
+ client = double(client)
123
+ client.should_receive(:get_file).with(any_args)
124
+
125
+ run = TestdroidApi::Client::Project::TestRun.new(client, project, {})
126
+ run.screenshots_zip
127
+ end
128
+ end
129
+
130
+ describe '#junit_results_zip' do
131
+ let(:url) { "https://cloud.testdroid.com/api/v1/projects/1/runs/10176/junits.zip" }
132
+ let(:response_body) {File.new(File.dirname(__FILE__) + "/fixtures/logs.zip")}
133
+ before do
134
+ stub_request(:get, url).
135
+ to_return(:status => 200, :body => response_body, :headers => {})
136
+ end
137
+
138
+ it 'sends the right request' do
139
+ test_run.junit_results_zip
140
+
141
+ a_request(:get, url).should have_been_made
142
+ end
143
+
144
+ it 'does not JSON parse response' do
145
+ client = double(client)
146
+ client.should_receive(:get_file).with(any_args)
147
+
148
+ run = TestdroidApi::Client::Project::TestRun.new(client, project, {})
149
+ run.junit_results_zip
150
+ end
151
+ end
152
+
153
+ describe '#results' do
154
+ it 'is not implemented' do
155
+ expect {test_run.results}.to raise_error(NotImplementedError)
156
+ end
157
+ end
158
+ end
159
+ end