leantesting 1.0.1 → 1.0.2
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/README.md +2 -2
- data/leantesting.gemspec +1 -1
- data/lib/BaseClass/APIRequest.rb +154 -151
- data/lib/BaseClass/Entity.rb +25 -24
- data/lib/BaseClass/EntityHandler.rb +151 -149
- data/lib/BaseClass/EntityList.rb +163 -161
- data/lib/Entity/Bug/Bug.rb +10 -8
- data/lib/Entity/Bug/BugAttachment.rb +7 -5
- data/lib/Entity/Bug/BugComment.rb +7 -5
- data/lib/Entity/Platform/PlatformBrowser.rb +9 -7
- data/lib/Entity/Platform/PlatformBrowserVersion.rb +7 -5
- data/lib/Entity/Platform/PlatformDevice.rb +7 -5
- data/lib/Entity/Platform/PlatformOS.rb +9 -7
- data/lib/Entity/Platform/PlatformOSVersion.rb +7 -5
- data/lib/Entity/Platform/PlatformType.rb +9 -7
- data/lib/Entity/Project/Project.rb +24 -22
- data/lib/Entity/Project/ProjectBugScheme.rb +7 -5
- data/lib/Entity/Project/ProjectSection.rb +7 -5
- data/lib/Entity/Project/ProjectUser.rb +7 -5
- data/lib/Entity/Project/ProjectVersion.rb +7 -5
- data/lib/Entity/User/UserOrganization.rb +7 -5
- data/lib/Exception/BaseException/SDKException.rb +15 -13
- data/lib/Exception/SDKBadJSONResponseException.rb +13 -11
- data/lib/Exception/SDKDuplicateRequestException.rb +15 -13
- data/lib/Exception/SDKErrorResponseException.rb +12 -10
- data/lib/Exception/SDKIncompleteRequestException.rb +15 -13
- data/lib/Exception/SDKInvalidArgException.rb +13 -11
- data/lib/Exception/SDKMissingArgException.rb +13 -11
- data/lib/Exception/SDKUnexpectedResponseException.rb +13 -11
- data/lib/Exception/SDKUnsupportedRequestException.rb +15 -13
- data/lib/Handler/Attachment/AttachmentsHandler.rb +14 -12
- data/lib/Handler/Auth/OAuth2Handler.rb +102 -100
- data/lib/Handler/Bug/BugAttachmentsHandler.rb +44 -42
- data/lib/Handler/Bug/BugCommentsHandler.rb +16 -14
- data/lib/Handler/Bug/BugsHandler.rb +53 -51
- data/lib/Handler/Platform/PlatformBrowserVersionsHandler.rb +16 -14
- data/lib/Handler/Platform/PlatformBrowsersHandler.rb +18 -16
- data/lib/Handler/Platform/PlatformDevicesHandler.rb +9 -7
- data/lib/Handler/Platform/PlatformHandler.rb +20 -18
- data/lib/Handler/Platform/PlatformOSHandler.rb +18 -16
- data/lib/Handler/Platform/PlatformOSVersionsHandler.rb +16 -14
- data/lib/Handler/Platform/PlatformTypeDevicesHandler.rb +16 -14
- data/lib/Handler/Platform/PlatformTypesHandler.rb +17 -15
- data/lib/Handler/Project/ProjectBugReproducibilitySchemeHandler.rb +16 -14
- data/lib/Handler/Project/ProjectBugSeveritySchemeHandler.rb +16 -14
- data/lib/Handler/Project/ProjectBugStatusSchemeHandler.rb +16 -14
- data/lib/Handler/Project/ProjectBugTypeSchemeHandler.rb +16 -14
- data/lib/Handler/Project/ProjectBugsHandler.rb +55 -53
- data/lib/Handler/Project/ProjectSectionsHandler.rb +30 -28
- data/lib/Handler/Project/ProjectUsersHandler.rb +16 -14
- data/lib/Handler/Project/ProjectVersionsHandler.rb +30 -28
- data/lib/Handler/Project/ProjectsHandler.rb +34 -32
- data/lib/Handler/User/UserHandler.rb +12 -10
- data/lib/Handler/User/UserOrganizationsHandler.rb +12 -10
- data/tests/APIRequestTest.rb +33 -33
- data/tests/BaseClassesTest.rb +28 -28
- data/tests/ClientTest.rb +7 -7
- data/tests/EntitiesTest.rb +31 -31
- data/tests/EntityListTest.rb +13 -13
- data/tests/ExceptionsTest.rb +15 -15
- data/tests/HandlersRequestsTest.rb +37 -37
- data/tests/MockRequestsTest.rb +48 -48
- data/tests/OAuth2HandlerTest.rb +19 -19
- metadata +2 -1
data/lib/BaseClass/EntityList.rb
CHANGED
@@ -1,188 +1,190 @@
|
|
1
1
|
#
|
2
2
|
# An EntityList is a list of Entity objects, obtained from compiling the results of an all() call.
|
3
3
|
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
filters
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
4
|
+
module LeanTesting
|
5
|
+
class EntityList
|
6
|
+
attr_reader :collection
|
7
|
+
|
8
|
+
@origin = nil # Reference to originating Client instance
|
9
|
+
|
10
|
+
@identifier = nil # Class definition identifier for the collection Entities
|
11
|
+
@collection = nil # Internal collection corresponding to current page
|
12
|
+
|
13
|
+
@request = nil # APIRequest definition to use for collection generation
|
14
|
+
@filters = nil # Filter list for generation (origins in Handler call)
|
15
|
+
|
16
|
+
@pagination = nil # Pagination object as per response (without links)
|
17
|
+
|
18
|
+
#
|
19
|
+
# Constructs an Entity List instance.
|
20
|
+
#
|
21
|
+
# Arguments:
|
22
|
+
# origin Client -- Original client instance reference
|
23
|
+
# request APIRequest -- An API Request definition given by the entity collection handler. This is used for any
|
24
|
+
# subsequent collection regeneration, as any data updates are dependant on external requests.
|
25
|
+
# identifier Class -- class definition to use for dynamic class instancing within array collection
|
26
|
+
# filters Hash -- original filters passed over from originating all() call
|
27
|
+
#
|
28
|
+
def initialize(origin, request, identifier, filters = nil)
|
29
|
+
if !filters
|
30
|
+
filters = {}
|
31
|
+
end
|
32
|
+
|
33
|
+
@origin = origin
|
34
|
+
@request = request
|
35
|
+
@identifier = identifier
|
36
|
+
@filters = filters
|
37
|
+
|
38
|
+
generateCollectionData
|
38
39
|
|
39
|
-
end
|
40
|
-
|
41
|
-
#
|
42
|
-
# Sets iterator position to first page. Ignored if already on first page.
|
43
|
-
#
|
44
|
-
def first
|
45
|
-
if @pagination['current_page'] == 1
|
46
|
-
return false
|
47
40
|
end
|
48
41
|
|
49
|
-
|
50
|
-
|
51
|
-
|
42
|
+
#
|
43
|
+
# Sets iterator position to first page. Ignored if already on first page.
|
44
|
+
#
|
45
|
+
def first
|
46
|
+
if @pagination['current_page'] == 1
|
47
|
+
return false
|
48
|
+
end
|
52
49
|
|
53
|
-
|
54
|
-
|
55
|
-
#
|
56
|
-
def previous
|
57
|
-
if @pagination['current_page'] == 1
|
58
|
-
return false
|
50
|
+
@filters['page'] = 1
|
51
|
+
generateCollectionData
|
59
52
|
end
|
60
53
|
|
61
|
-
|
62
|
-
|
63
|
-
|
54
|
+
#
|
55
|
+
# Sets iterator position to previous page. Ignored if on first page.
|
56
|
+
#
|
57
|
+
def previous
|
58
|
+
if @pagination['current_page'] == 1
|
59
|
+
return false
|
60
|
+
end
|
64
61
|
|
65
|
-
|
66
|
-
|
67
|
-
#
|
68
|
-
def next
|
69
|
-
if @pagination['current_page'] == @pagination['total_pages']
|
70
|
-
return false
|
62
|
+
@filters['page'] -=1
|
63
|
+
generateCollectionData
|
71
64
|
end
|
72
65
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
66
|
+
#
|
67
|
+
# Sets iterator position to next page. Ignored if on last page.
|
68
|
+
#
|
69
|
+
def next
|
70
|
+
if @pagination['current_page'] == @pagination['total_pages']
|
71
|
+
return false
|
72
|
+
end
|
73
|
+
|
74
|
+
if @filters.has_key? 'page'
|
75
|
+
@filters['page'] += 1
|
76
|
+
else
|
77
|
+
@filters['page'] = 2
|
78
|
+
end
|
79
|
+
|
80
|
+
generateCollectionData
|
77
81
|
end
|
78
82
|
|
79
|
-
|
80
|
-
|
83
|
+
#
|
84
|
+
# Sets iterator position to last page. Ignored if already on last page.
|
85
|
+
#
|
86
|
+
def last
|
87
|
+
if @pagination['current_page'] == @pagination['total_pages']
|
88
|
+
return false
|
89
|
+
end
|
81
90
|
|
82
|
-
|
83
|
-
|
84
|
-
#
|
85
|
-
def last
|
86
|
-
if @pagination['current_page'] == @pagination['total_pages']
|
87
|
-
return false
|
91
|
+
@filters['page'] = @pagination['total_pages']
|
92
|
+
generateCollectionData
|
88
93
|
end
|
89
94
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
begin
|
100
|
-
yield toArray
|
101
|
-
end while self.next
|
102
|
-
end
|
103
|
-
|
104
|
-
#
|
105
|
-
# Outputs total number of Entities inside multi-page collection
|
106
|
-
#
|
107
|
-
# Returns:
|
108
|
-
# Fixnum -- Number of total Entities
|
109
|
-
#
|
110
|
-
def total
|
111
|
-
@pagination['total']
|
112
|
-
end
|
113
|
-
|
114
|
-
#
|
115
|
-
# Outputs total number of pages the multi-page collection has, regardful of limit/per_page
|
116
|
-
#
|
117
|
-
# Returns:
|
118
|
-
# Fixnum -- Number of total pages
|
119
|
-
#
|
120
|
-
def totalPages
|
121
|
-
@pagination['total_pages']
|
122
|
-
end
|
123
|
-
|
124
|
-
#
|
125
|
-
# Outputs number of Entities in current collection page. Will always be same as limmit/per_page if not on last page.
|
126
|
-
#
|
127
|
-
# Returns:
|
128
|
-
# Fixnum -- Number of Entities in page
|
129
|
-
#
|
130
|
-
def count
|
131
|
-
@pagination['count']
|
132
|
-
end
|
95
|
+
#
|
96
|
+
# Internal loop handler for emulating enumerable functionality
|
97
|
+
#
|
98
|
+
def each
|
99
|
+
first
|
100
|
+
begin
|
101
|
+
yield toArray
|
102
|
+
end while self.next
|
103
|
+
end
|
133
104
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
105
|
+
#
|
106
|
+
# Outputs total number of Entities inside multi-page collection
|
107
|
+
#
|
108
|
+
# Returns:
|
109
|
+
# Fixnum -- Number of total Entities
|
110
|
+
#
|
111
|
+
def total
|
112
|
+
@pagination['total']
|
113
|
+
end
|
143
114
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
# SDKUnexpectedResponseException if no `meta` field is found
|
153
|
-
# SDKUnexpectedResponseException if no `pagination` field is found in `meta field`
|
154
|
-
# SDKUnexpectedResponseException if no collection set is found
|
155
|
-
# SDKUnexpectedResponseException if multiple collection sets are found
|
156
|
-
#
|
157
|
-
def generateCollectionData
|
158
|
-
@collection = [] # Clear previous collection data on fresh regeneration
|
159
|
-
@pagination = {} # Clear previous pagination data on fresh regeneration
|
160
|
-
|
161
|
-
@request.updateOpts({'params' => @filters})
|
162
|
-
raw = @request.exec
|
163
|
-
|
164
|
-
if !raw.has_key? 'meta'
|
165
|
-
raise SDKUnexpectedResponseException, 'missing `meta` field'
|
166
|
-
elsif !raw['meta'].has_key? 'pagination'
|
167
|
-
raise SDKUnexpectedResponseException, '`meta` missing `pagination` field'
|
115
|
+
#
|
116
|
+
# Outputs total number of pages the multi-page collection has, regardful of limit/per_page
|
117
|
+
#
|
118
|
+
# Returns:
|
119
|
+
# Fixnum -- Number of total pages
|
120
|
+
#
|
121
|
+
def totalPages
|
122
|
+
@pagination['total_pages']
|
168
123
|
end
|
169
124
|
|
170
|
-
|
171
|
-
|
125
|
+
#
|
126
|
+
# Outputs number of Entities in current collection page. Will always be same as limmit/per_page if not on last page.
|
127
|
+
#
|
128
|
+
# Returns:
|
129
|
+
# Fixnum -- Number of Entities in page
|
130
|
+
#
|
131
|
+
def count
|
132
|
+
@pagination['count']
|
172
133
|
end
|
173
134
|
|
174
|
-
|
175
|
-
|
135
|
+
#
|
136
|
+
# Outputs internal collection in array format (converted from Entity objects)
|
137
|
+
#
|
138
|
+
# Returns:
|
139
|
+
# Array -- array of elements converted into hashes
|
140
|
+
#
|
141
|
+
def toArray
|
142
|
+
@collection.map{ |entity| entity.data }
|
143
|
+
end
|
176
144
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
145
|
+
private
|
146
|
+
|
147
|
+
#
|
148
|
+
# (Re)generates internal collection data based on current iteration position.
|
149
|
+
#
|
150
|
+
# Regeneration is done every time position changes (i.e. every time repositioning functions are used).
|
151
|
+
#
|
152
|
+
# Exceptions:
|
153
|
+
# SDKUnexpectedResponseException if no `meta` field is found
|
154
|
+
# SDKUnexpectedResponseException if no `pagination` field is found in `meta field`
|
155
|
+
# SDKUnexpectedResponseException if no collection set is found
|
156
|
+
# SDKUnexpectedResponseException if multiple collection sets are found
|
157
|
+
#
|
158
|
+
def generateCollectionData
|
159
|
+
@collection = [] # Clear previous collection data on fresh regeneration
|
160
|
+
@pagination = {} # Clear previous pagination data on fresh regeneration
|
161
|
+
|
162
|
+
@request.updateOpts({'params' => @filters})
|
163
|
+
raw = @request.exec
|
164
|
+
|
165
|
+
if !raw.has_key? 'meta'
|
166
|
+
raise SDKUnexpectedResponseException, 'missing `meta` field'
|
167
|
+
elsif !raw['meta'].has_key? 'pagination'
|
168
|
+
raise SDKUnexpectedResponseException, '`meta` missing `pagination` field'
|
169
|
+
end
|
170
|
+
|
171
|
+
if raw['meta']['pagination'].has_key? 'links'
|
172
|
+
raw['meta']['pagination'].delete('links') # Remove not needed links sub-data
|
173
|
+
end
|
174
|
+
|
175
|
+
@pagination = raw['meta']['pagination'] # Pass pagination data as per response meta key
|
176
|
+
raw.delete('meta')
|
177
|
+
|
178
|
+
if raw.length.zero?
|
179
|
+
raise SDKUnexpectedResponseException, 'collection object missing'
|
180
|
+
elsif raw.length > 1
|
181
|
+
cols = raw.map{ |k,| k }.join(', ')
|
182
|
+
raise SDKUnexpectedResponseException, 'expected one collection object, multiple received: ' + cols
|
183
|
+
end
|
184
|
+
|
185
|
+
classDef = @identifier # Definition to be used for dynamic Entity instancing
|
186
|
+
raw.values[0].each{ |entity| @collection.push(classDef.new(@origin, entity)) }
|
182
187
|
end
|
183
188
|
|
184
|
-
classDef = @identifier # Definition to be used for dynamic Entity instancing
|
185
|
-
raw.values[0].each{ |entity| @collection.push(classDef.new(@origin, entity)) }
|
186
189
|
end
|
187
|
-
|
188
|
-
end
|
190
|
+
end
|
data/lib/Entity/Bug/Bug.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module LeanTesting
|
2
|
+
class Bug < LeanTesting::Entity
|
3
|
+
attr_reader :comments, :attachments
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
def initialize(origin, data)
|
6
|
+
super
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
@comments = BugCommentsHandler.new(origin, data['id'])
|
9
|
+
@attachments = BugAttachmentsHandler.new(origin, data['id'])
|
10
|
+
end
|
10
11
|
|
11
|
-
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,10 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module LeanTesting
|
2
|
+
class PlatformBrowser < LeanTesting::Entity
|
3
|
+
attr_reader :versions
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
def initialize(origin, data)
|
6
|
+
super
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
@versions = PlatformBrowserVersionsHandler.new(origin, data['id'])
|
9
|
+
end
|
9
10
|
|
10
|
-
end
|
11
|
+
end
|
12
|
+
end
|