leantesting 1.0.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 +7 -0
- data/Gemfile +9 -0
- data/LICENSE +10 -0
- data/README.md +348 -0
- data/Rakefile +9 -0
- data/leantesting.gemspec +20 -0
- data/lib/BaseClass/APIRequest.rb +195 -0
- data/lib/BaseClass/Entity.rb +33 -0
- data/lib/BaseClass/EntityHandler.rb +183 -0
- data/lib/BaseClass/EntityList.rb +188 -0
- data/lib/Entity/Bug/Bug.rb +11 -0
- data/lib/Entity/Bug/BugAttachment.rb +7 -0
- data/lib/Entity/Bug/BugComment.rb +7 -0
- data/lib/Entity/Platform/PlatformBrowser.rb +10 -0
- data/lib/Entity/Platform/PlatformBrowserVersion.rb +7 -0
- data/lib/Entity/Platform/PlatformDevice.rb +7 -0
- data/lib/Entity/Platform/PlatformOS.rb +10 -0
- data/lib/Entity/Platform/PlatformOSVersion.rb +7 -0
- data/lib/Entity/Platform/PlatformType.rb +10 -0
- data/lib/Entity/Project/Project.rb +27 -0
- data/lib/Entity/Project/ProjectBugScheme.rb +7 -0
- data/lib/Entity/Project/ProjectSection.rb +7 -0
- data/lib/Entity/Project/ProjectUser.rb +7 -0
- data/lib/Entity/Project/ProjectVersion.rb +7 -0
- data/lib/Entity/User/UserOrganization.rb +7 -0
- data/lib/Exception/BaseException/SDKException.rb +19 -0
- data/lib/Exception/SDKBadJSONResponseException.rb +15 -0
- data/lib/Exception/SDKDuplicateRequestException.rb +19 -0
- data/lib/Exception/SDKErrorResponseException.rb +13 -0
- data/lib/Exception/SDKIncompleteRequestException.rb +19 -0
- data/lib/Exception/SDKInvalidArgException.rb +15 -0
- data/lib/Exception/SDKMissingArgException.rb +15 -0
- data/lib/Exception/SDKUnexpectedResponseException.rb +15 -0
- data/lib/Exception/SDKUnsupportedRequestException.rb +19 -0
- data/lib/Handler/Attachment/AttachmentsHandler.rb +17 -0
- data/lib/Handler/Auth/OAuth2Handler.rb +118 -0
- data/lib/Handler/Bug/BugAttachmentsHandler.rb +51 -0
- data/lib/Handler/Bug/BugCommentsHandler.rb +20 -0
- data/lib/Handler/Bug/BugsHandler.rb +57 -0
- data/lib/Handler/Platform/PlatformBrowserVersionsHandler.rb +20 -0
- data/lib/Handler/Platform/PlatformBrowsersHandler.rb +23 -0
- data/lib/Handler/Platform/PlatformDevicesHandler.rb +10 -0
- data/lib/Handler/Platform/PlatformHandler.rb +22 -0
- data/lib/Handler/Platform/PlatformOSHandler.rb +23 -0
- data/lib/Handler/Platform/PlatformOSVersionsHandler.rb +20 -0
- data/lib/Handler/Platform/PlatformTypeDevicesHandler.rb +20 -0
- data/lib/Handler/Platform/PlatformTypesHandler.rb +21 -0
- data/lib/Handler/Project/ProjectBugReproducibilitySchemeHandler.rb +20 -0
- data/lib/Handler/Project/ProjectBugSeveritySchemeHandler.rb +20 -0
- data/lib/Handler/Project/ProjectBugStatusSchemeHandler.rb +20 -0
- data/lib/Handler/Project/ProjectBugTypeSchemeHandler.rb +20 -0
- data/lib/Handler/Project/ProjectBugsHandler.rb +67 -0
- data/lib/Handler/Project/ProjectSectionsHandler.rb +39 -0
- data/lib/Handler/Project/ProjectUsersHandler.rb +20 -0
- data/lib/Handler/Project/ProjectVersionsHandler.rb +39 -0
- data/lib/Handler/Project/ProjectsHandler.rb +46 -0
- data/lib/Handler/User/UserHandler.rb +14 -0
- data/lib/Handler/User/UserOrganizationsHandler.rb +14 -0
- data/lib/leantesting.rb +65 -0
- data/lib/loader.rb +18 -0
- data/tests/APIRequestTest.rb +152 -0
- data/tests/BaseClassesTest.rb +96 -0
- data/tests/ClientTest.rb +52 -0
- data/tests/EntitiesTest.rb +97 -0
- data/tests/EntityListTest.rb +51 -0
- data/tests/ExceptionsTest.rb +70 -0
- data/tests/HandlersRequestsTest.rb +215 -0
- data/tests/MockRequestsTest.rb +556 -0
- data/tests/OAuth2HandlerTest.rb +75 -0
- data/tests/res/upload_sample.jpg +0 -0
- metadata +169 -0
@@ -0,0 +1,556 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require(:default, :test)
|
3
|
+
|
4
|
+
require_relative '../lib/Client'
|
5
|
+
|
6
|
+
class MockRequestsTest < MiniTest::Test
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@client = Client.new
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def rint(min = 100, max = 9999999)
|
15
|
+
rand(min..max)
|
16
|
+
end
|
17
|
+
def rstr(ln = nil)
|
18
|
+
if !ln
|
19
|
+
ln = rint(1, 15)
|
20
|
+
end
|
21
|
+
|
22
|
+
c = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
23
|
+
s = ''
|
24
|
+
|
25
|
+
(0..ln).each{ |i| s += c[rand(0..c.length) - 1] }
|
26
|
+
|
27
|
+
s
|
28
|
+
end
|
29
|
+
def robj(fields)
|
30
|
+
obj = {}
|
31
|
+
|
32
|
+
fields.each do |f|
|
33
|
+
if f[0] == '_'
|
34
|
+
obj[f[1..-1]] = rint
|
35
|
+
else
|
36
|
+
obj[f] = rstr
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
obj
|
41
|
+
end
|
42
|
+
def rcol(name, fields)
|
43
|
+
col = {}
|
44
|
+
col[name] = []
|
45
|
+
|
46
|
+
(0..rint(1, 7)).each{ |i| col[name].push(robj(fields)) }
|
47
|
+
|
48
|
+
totalPages = rint(2, 15)
|
49
|
+
count = col[name].length
|
50
|
+
perPage = count
|
51
|
+
total = totalPages * perPage
|
52
|
+
|
53
|
+
col['meta'] = {
|
54
|
+
'pagination'=> {
|
55
|
+
'total'=> total,
|
56
|
+
'count'=> count,
|
57
|
+
'per_page'=> perPage,
|
58
|
+
'current_page'=> rint(1, totalPages),
|
59
|
+
'total_pages'=> totalPages,
|
60
|
+
'links'=> {}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
col
|
65
|
+
end
|
66
|
+
|
67
|
+
public
|
68
|
+
|
69
|
+
# USER
|
70
|
+
def test_GetUserInformation
|
71
|
+
resp = robj(['first_name', 'created_at', '_id', 'last_name', 'avatar', 'email', 'username'])
|
72
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
73
|
+
|
74
|
+
data = @client.user.getInformation
|
75
|
+
|
76
|
+
assert_equal resp, data
|
77
|
+
end
|
78
|
+
def test_GetUserOrganizations
|
79
|
+
colName = 'organizations'
|
80
|
+
retClass = UserOrganization
|
81
|
+
resp = rcol(colName, ['_id', 'name', 'alias', 'url', 'logo'])
|
82
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
83
|
+
|
84
|
+
col = @client.user.organizations.all
|
85
|
+
|
86
|
+
assert_equal resp[colName], col.toArray
|
87
|
+
assert_instance_of retClass, col.collection[0]
|
88
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
89
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
90
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
91
|
+
end
|
92
|
+
# END USER
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
# PROJECT
|
100
|
+
def test_ListAllProjects
|
101
|
+
colName = 'projects'
|
102
|
+
retClass = Project
|
103
|
+
resp = rcol(colName, ['_id', 'name', '_owner_id', '_organization_id', '_is_archived', 'created_at'])
|
104
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
105
|
+
|
106
|
+
col = @client.projects.all
|
107
|
+
|
108
|
+
assert_equal resp[colName], col.toArray
|
109
|
+
assert_instance_of retClass, col.collection[0]
|
110
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
111
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
112
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
113
|
+
end
|
114
|
+
def test_CreateNewProject
|
115
|
+
retClass = Project
|
116
|
+
resp = robj(['_id', 'name', '_owner_id', '_organization_id', '_is_archived', 'created_at'])
|
117
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
118
|
+
|
119
|
+
obj = @client.projects.create({
|
120
|
+
'name'=> '', 'organization_id'=> 0
|
121
|
+
})
|
122
|
+
|
123
|
+
assert_equal resp, obj.data
|
124
|
+
assert_instance_of retClass, obj
|
125
|
+
end
|
126
|
+
def test_RetrieveExistingProject
|
127
|
+
retClass = Project
|
128
|
+
resp = robj(['_id', 'name', '_owner_id', '_organization_id', '_is_archived', 'created_at'])
|
129
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
130
|
+
|
131
|
+
obj = @client.projects.find(0)
|
132
|
+
|
133
|
+
assert_equal resp, obj.data
|
134
|
+
assert_instance_of retClass, obj
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
def test_ListProjectSections
|
139
|
+
colName = 'sections'
|
140
|
+
retClass = ProjectSection
|
141
|
+
resp = rcol(colName, ['_id', 'name', '_project_id'])
|
142
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
143
|
+
|
144
|
+
col = Project.new(@client, {'id'=> 0}).sections.all
|
145
|
+
|
146
|
+
assert_equal resp[colName], col.toArray
|
147
|
+
assert_instance_of retClass, col.collection[0]
|
148
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
149
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
150
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
151
|
+
end
|
152
|
+
def test_AddProjectSection
|
153
|
+
retClass = ProjectSection
|
154
|
+
resp = robj(['_id', 'name', '_project_id'])
|
155
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
156
|
+
|
157
|
+
obj = Project.new(@client, {'id'=> 0}).sections.create({
|
158
|
+
'name'=> ''
|
159
|
+
})
|
160
|
+
|
161
|
+
assert_equal resp, obj.data
|
162
|
+
assert_instance_of retClass, obj
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
def test_ListProjectVersions
|
167
|
+
colName = 'versions'
|
168
|
+
retClass = ProjectVersion
|
169
|
+
resp = rcol(colName, ['_id', 'number', '_project_id'])
|
170
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
171
|
+
|
172
|
+
col = Project.new(@client, {'id'=> 0}).versions.all
|
173
|
+
|
174
|
+
assert_equal resp[colName], col.toArray
|
175
|
+
assert_instance_of retClass, col.collection[0]
|
176
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
177
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
178
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
179
|
+
end
|
180
|
+
def test_AddProjectVersion
|
181
|
+
retClass = ProjectVersion
|
182
|
+
resp = robj(['_id', 'number', '_project_id'])
|
183
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
184
|
+
|
185
|
+
obj = Project.new(@client, {'id'=> 0}).versions.create({
|
186
|
+
'number'=> ''
|
187
|
+
})
|
188
|
+
|
189
|
+
assert_equal resp, obj.data
|
190
|
+
assert_instance_of retClass, obj
|
191
|
+
end
|
192
|
+
|
193
|
+
|
194
|
+
def test_ListProjectUsers
|
195
|
+
colName = 'users'
|
196
|
+
retClass = ProjectUser
|
197
|
+
resp = rcol(colName, ['_id', 'username', 'first_name', 'last_name', 'avatar', 'email', 'created_at'])
|
198
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
199
|
+
|
200
|
+
col = Project.new(@client, {'id'=> 0}).users.all
|
201
|
+
|
202
|
+
assert_equal resp[colName], col.toArray
|
203
|
+
assert_instance_of retClass, col.collection[0]
|
204
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
205
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
206
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
def test_ListProjectBugTypeScheme
|
211
|
+
colName = 'scheme'
|
212
|
+
retClass = ProjectBugScheme
|
213
|
+
resp = rcol(colName, ['_id', 'name'])
|
214
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
215
|
+
|
216
|
+
col = Project.new(@client, {'id'=> 0}).bugTypeScheme.all
|
217
|
+
|
218
|
+
assert_equal resp[colName], col.toArray
|
219
|
+
assert_instance_of retClass, col.collection[0]
|
220
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
221
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
222
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
223
|
+
end
|
224
|
+
def test_ListProjectBugStatusScheme
|
225
|
+
colName = 'scheme'
|
226
|
+
retClass = ProjectBugScheme
|
227
|
+
resp = rcol(colName, ['_id', 'name'])
|
228
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
229
|
+
|
230
|
+
col = Project.new(@client, {'id'=> 0}).bugStatusScheme.all
|
231
|
+
|
232
|
+
assert_equal resp[colName], col.toArray
|
233
|
+
assert_instance_of retClass, col.collection[0]
|
234
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
235
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
236
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
237
|
+
end
|
238
|
+
def test_ListProjectBugSeverityScheme
|
239
|
+
colName = 'scheme'
|
240
|
+
retClass = ProjectBugScheme
|
241
|
+
resp = rcol(colName, ['_id', 'name'])
|
242
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
243
|
+
|
244
|
+
col = Project.new(@client, {'id'=> 0}).bugSeverityScheme.all
|
245
|
+
|
246
|
+
assert_equal resp[colName], col.toArray
|
247
|
+
assert_instance_of retClass, col.collection[0]
|
248
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
249
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
250
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
251
|
+
end
|
252
|
+
def test_ListProjectBugReproducibilityScheme
|
253
|
+
colName = 'scheme'
|
254
|
+
retClass = ProjectBugScheme
|
255
|
+
resp = rcol(colName, ['_id', 'name'])
|
256
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
257
|
+
|
258
|
+
col = Project.new(@client, {'id'=> 0}).bugReproducibilityScheme.all
|
259
|
+
|
260
|
+
assert_equal resp[colName], col.toArray
|
261
|
+
assert_instance_of retClass, col.collection[0]
|
262
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
263
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
264
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
265
|
+
end
|
266
|
+
# END PROJECT
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
# BUG
|
276
|
+
def test_ListBugsInProject
|
277
|
+
colName = 'bugs'
|
278
|
+
retClass = Bug
|
279
|
+
resp = rcol(colName, ['_id', 'title', '_status_id', '_severity_id', '_project_version_id',
|
280
|
+
'_project_section_id', '_type_id', '_reproducibility_id', '_assigned_user_id', 'description',
|
281
|
+
'expected_results'])
|
282
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
283
|
+
|
284
|
+
col = Project.new(@client, {'id'=> 0}).bugs.all
|
285
|
+
|
286
|
+
assert_equal resp[colName], col.toArray
|
287
|
+
assert_instance_of retClass, col.collection[0]
|
288
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
289
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
290
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
291
|
+
end
|
292
|
+
def test_CreateNewBug
|
293
|
+
retClass = Bug
|
294
|
+
resp = robj(['_id', 'title', '_status_id', '_severity_id', '_project_version_id',
|
295
|
+
'_project_section_id', '_type_id', '_reproducibility_id', '_assigned_user_id', 'description',
|
296
|
+
'expected_results'])
|
297
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
298
|
+
|
299
|
+
obj = Project.new(@client, {'id'=> 0}).bugs.create({
|
300
|
+
'title'=> '', 'status_id'=> 0, 'severity_id'=> 0, 'project_version_id'=> 0, 'project_section_id'=> 0,
|
301
|
+
'type_id'=> 0, 'reproducibility_id'=> 0, 'assigned_user_id'=> 0, 'description'=> '',
|
302
|
+
'expected_results'=> ''
|
303
|
+
})
|
304
|
+
|
305
|
+
assert_equal resp, obj.data
|
306
|
+
assert_instance_of retClass, obj
|
307
|
+
end
|
308
|
+
def test_RetrieveExistingBug
|
309
|
+
retClass = Bug
|
310
|
+
resp = robj(['_id', 'title', '_status_id', '_severity_id', '_project_version_id',
|
311
|
+
'_project_section_id', '_type_id', '_reproducibility_id', '_assigned_user_id', 'description',
|
312
|
+
'expected_results'])
|
313
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
314
|
+
|
315
|
+
obj = @client.bugs.find(0)
|
316
|
+
|
317
|
+
assert_equal resp, obj.data
|
318
|
+
assert_instance_of retClass, obj
|
319
|
+
end
|
320
|
+
def test_UpdateBug
|
321
|
+
retClass = Bug
|
322
|
+
resp = robj(['_id', 'title', '_status_id', '_severity_id', '_project_version_id',
|
323
|
+
'_project_section_id', '_type_id', '_reproducibility_id', '_assigned_user_id', 'description',
|
324
|
+
'expected_results'])
|
325
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
326
|
+
|
327
|
+
obj = @client.bugs.update(0, {
|
328
|
+
'title'=> '', 'status_id'=> 0, 'severity_id'=> 0, 'project_version_id'=> 0, 'project_section_id'=> 0,
|
329
|
+
'type_id'=> 0, 'assigned_user_id'=> 0, 'description'=> '', 'expected_results'=> ''
|
330
|
+
})
|
331
|
+
|
332
|
+
assert_equal resp, obj.data
|
333
|
+
assert_instance_of retClass, obj
|
334
|
+
end
|
335
|
+
def test_DeleteBug
|
336
|
+
@client.debugReturn = {'data'=> nil, 'status'=> 204}
|
337
|
+
|
338
|
+
data = @client.bugs.delete(0)
|
339
|
+
|
340
|
+
assert data == true
|
341
|
+
end
|
342
|
+
# END BUG
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
# BUG COMMENTS
|
351
|
+
def test_ListBugComments
|
352
|
+
colName = 'comments'
|
353
|
+
retClass = BugComment
|
354
|
+
resp = rcol(colName, ['_id', 'text', '_owner_id', 'created_at'])
|
355
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
356
|
+
|
357
|
+
col = Bug.new(@client, {'id'=> 0}).comments.all
|
358
|
+
|
359
|
+
assert_equal resp[colName], col.toArray
|
360
|
+
assert_instance_of retClass, col.collection[0]
|
361
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
362
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
363
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
364
|
+
end
|
365
|
+
# END BUG COMMENTS
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
# BUG ATTACHMENTS
|
375
|
+
def test_ListBugAttachments
|
376
|
+
colName = 'attachments'
|
377
|
+
retClass = BugAttachment
|
378
|
+
resp = rcol(colName, ['_id', '_owner_id', 'url', 'created_at'])
|
379
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
380
|
+
|
381
|
+
col = Bug.new(@client, {'id'=> 0}).attachments.all
|
382
|
+
|
383
|
+
assert_equal resp[colName], col.toArray
|
384
|
+
assert_instance_of retClass, col.collection[0]
|
385
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
386
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
387
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
388
|
+
end
|
389
|
+
def test_CreateNewAttachment
|
390
|
+
retClass = BugAttachment
|
391
|
+
resp = robj(['_id', '_owner_id', 'url', 'created_at'])
|
392
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
393
|
+
|
394
|
+
_fp = File.expand_path(File.dirname(__FILE__)) + '/res/upload_sample.jpg'
|
395
|
+
obj = Bug.new(@client, {'id'=> 0}).attachments.upload(_fp)
|
396
|
+
|
397
|
+
assert_equal resp, obj.data
|
398
|
+
assert_instance_of retClass, obj
|
399
|
+
end
|
400
|
+
def test_RetrieveExistingAttachment
|
401
|
+
retClass = BugAttachment
|
402
|
+
resp = robj(['_id', '_owner_id', 'url', 'created_at'])
|
403
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
404
|
+
|
405
|
+
obj = @client.attachments.find(0)
|
406
|
+
|
407
|
+
assert_equal resp, obj.data
|
408
|
+
assert_instance_of retClass, obj
|
409
|
+
end
|
410
|
+
def test_DeleteAttachment
|
411
|
+
@client.debugReturn = {'data'=> nil, 'status'=> 204}
|
412
|
+
|
413
|
+
data = @client.attachments.delete(0)
|
414
|
+
|
415
|
+
assert data == true
|
416
|
+
end
|
417
|
+
# END BUG ATTACHMENTS
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
# PLATFORM
|
427
|
+
def test_ListPlatformTypes
|
428
|
+
colName = 'types'
|
429
|
+
retClass = PlatformType
|
430
|
+
resp = rcol(colName, ['_id', 'name'])
|
431
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
432
|
+
|
433
|
+
col = @client.platform.types.all
|
434
|
+
|
435
|
+
assert_equal resp[colName], col.toArray
|
436
|
+
assert_instance_of retClass, col.collection[0]
|
437
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
438
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
439
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
440
|
+
end
|
441
|
+
def test_RetrievePlatformType
|
442
|
+
retClass = PlatformType
|
443
|
+
resp = robj(['_id', 'name'])
|
444
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
445
|
+
|
446
|
+
obj = @client.platform.types.find(0)
|
447
|
+
|
448
|
+
assert_equal resp, obj.data
|
449
|
+
assert_instance_of retClass, obj
|
450
|
+
end
|
451
|
+
|
452
|
+
def test_ListPlatformDevices
|
453
|
+
colName = 'devices'
|
454
|
+
retClass = PlatformDevice
|
455
|
+
resp = rcol(colName, ['_id', 'name'])
|
456
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
457
|
+
|
458
|
+
col = PlatformType.new(@client, {'id'=> 0}).devices.all
|
459
|
+
|
460
|
+
assert_equal resp[colName], col.toArray
|
461
|
+
assert_instance_of retClass, col.collection[0]
|
462
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
463
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
464
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
465
|
+
end
|
466
|
+
def test_RetrievePlatformDevice
|
467
|
+
retClass = PlatformDevice
|
468
|
+
resp = robj(['_id', 'name'])
|
469
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
470
|
+
|
471
|
+
obj = @client.platform.devices.find(0)
|
472
|
+
|
473
|
+
assert_equal resp, obj.data
|
474
|
+
assert_instance_of retClass, obj
|
475
|
+
end
|
476
|
+
|
477
|
+
def test_ListOS
|
478
|
+
colName = 'os'
|
479
|
+
retClass = PlatformOS
|
480
|
+
resp = rcol(colName, ['_id', 'name'])
|
481
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
482
|
+
|
483
|
+
col = @client.platform.os.all
|
484
|
+
|
485
|
+
assert_equal resp[colName], col.toArray
|
486
|
+
assert_instance_of retClass, col.collection[0]
|
487
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
488
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
489
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
490
|
+
end
|
491
|
+
def test_RetrieveOS
|
492
|
+
retClass = PlatformOS
|
493
|
+
resp = robj(['_id', 'name'])
|
494
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
495
|
+
|
496
|
+
obj = @client.platform.os.find(0)
|
497
|
+
|
498
|
+
assert_equal resp, obj.data
|
499
|
+
assert_instance_of retClass, obj
|
500
|
+
end
|
501
|
+
def test_ListOSVersions
|
502
|
+
colName = 'versions'
|
503
|
+
retClass = PlatformOSVersion
|
504
|
+
resp = rcol(colName, ['_id', 'number'])
|
505
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
506
|
+
|
507
|
+
col = PlatformOS.new(@client, {'id'=> 0}).versions.all
|
508
|
+
|
509
|
+
assert_equal resp[colName], col.toArray
|
510
|
+
assert_instance_of retClass, col.collection[0]
|
511
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
512
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
513
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
514
|
+
end
|
515
|
+
|
516
|
+
def test_ListBrowsers
|
517
|
+
colName = 'browsers'
|
518
|
+
retClass = PlatformBrowser
|
519
|
+
resp = rcol(colName, ['_id', 'name'])
|
520
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
521
|
+
|
522
|
+
col = @client.platform.browsers.all
|
523
|
+
|
524
|
+
assert_equal resp[colName], col.toArray
|
525
|
+
assert_instance_of retClass, col.collection[0]
|
526
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
527
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
528
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
529
|
+
end
|
530
|
+
def test_RetrieveBrowser
|
531
|
+
retClass = PlatformBrowser
|
532
|
+
resp = robj(['_id', 'name'])
|
533
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
534
|
+
|
535
|
+
obj = @client.platform.browsers.find(0)
|
536
|
+
|
537
|
+
assert_equal resp, obj.data
|
538
|
+
assert_instance_of retClass, obj
|
539
|
+
end
|
540
|
+
def test_ListBrowserVersions
|
541
|
+
colName = 'versions'
|
542
|
+
retClass = PlatformBrowserVersion
|
543
|
+
resp = rcol(colName, ['_id', 'name'])
|
544
|
+
@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}
|
545
|
+
|
546
|
+
col = PlatformBrowser.new(@client, {'id'=> 0}).versions.all
|
547
|
+
|
548
|
+
assert_equal resp[colName], col.toArray
|
549
|
+
assert_instance_of retClass, col.collection[0]
|
550
|
+
assert_equal resp['meta']['pagination']['total'], col.total
|
551
|
+
assert_equal resp['meta']['pagination']['total_pages'], col.totalPages
|
552
|
+
assert_equal resp['meta']['pagination']['count'], col.count
|
553
|
+
end
|
554
|
+
# END PLATFORM
|
555
|
+
|
556
|
+
end
|