-
Notifications
You must be signed in to change notification settings - Fork 0
/
landgateapitestmodel.py
281 lines (255 loc) · 14.1 KB
/
landgateapitestmodel.py
1
2
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# Google's appengine python libraries.
from google.appengine.ext import ndb
from google.appengine.ext.ndb import polymodel
# Model classes
class TestCampaign(ndb.Model):
"""TestCampaign is a superclass meant to link many TestMasters
by a single parent ID."""
campaignName = ndb.StringProperty()
class ResultObject(polymodel.PolyModel):
"""An abstract superclass for all result classes."""
testID = ndb.StringProperty()
parentID = ndb.StringProperty()
datetime = ndb.DateTimeProperty()
success = ndb.BooleanProperty()
comment = ndb.StringProperty()
class TestMaster(ResultObject):
"""The main class, each TestMaster object represents a single test
from the user's point of view, but actually initiates many TestEndpoints."""
startDatetime = ndb.DateTimeProperty()
finishDatetime = ndb.DateTimeProperty()
deviceType = ndb.StringProperty()
deviceID = ndb.StringProperty()
iOSVersion = ndb.StringProperty()
# endpointResults - a list of TestEndpoint subclass objects, normally dozens of them.
# networkResults - a list of NetworkResult objects.
# locationResults - a list of LocationResult objects.
# pingResults - a list of PingResult objects.
class TestEndpoint(ResultObject):
"""An abstract superclass for all endpoint tests.
An actual test on a specific URL with parameters."""
startDatetime = ndb.DateTimeProperty()
finishDatetime = ndb.DateTimeProperty()
server = ndb.StringProperty()
dataset = ndb.StringProperty()
returnType = ndb.StringProperty()
testName = ndb.StringProperty()
httpMethod = ndb.StringProperty()
testedURL = ndb.StringProperty()
responseCode = ndb.IntegerProperty()
responseData = ndb.TextProperty()
errorResponse = ndb.StringProperty()
analysed = ndb.IntegerProperty()
"""Previously we needed separate subclasses of each TestEndpoint response
type as their responseData were stored in different properties
(JsonProperty(), ImageProperty() and StringProperty()).
It was recently discovered that the best method is make them all
TextProperty()'s so concrete subclasses aren't necessary anymore."""
# sub-subclasses for json, xml, images
# class ImageEndpoint(TestEndpoint):
# """An API endpoint test designed to return an image for example a WMTS call
# returning a map tile.
# Importantly, in order to transmit images in JSON we must first convert them
# to 64 bit text. We keep them in this format for ease of comparison to
# a reference copy of the image, and we do not plan to display images."""
# imageResponse = ndb.TextProperty()
#
#
# class XmlEndpoint(TestEndpoint):
# """A concrete class designed to hold a GML response from
# a test on an OGC API endpoint."""
# xmlResponse = ndb.TextProperty()
#
#
# class JsonEndpoint(TestEndpoint):
# """A concrete class to hold the JSON response from a
# test on a GeoJSON or EsriJson API endpoint.
# There is an ndb.JsonProperty object sounds perfect for this use case.
# Unfortunately, we can not be assured of receiving well formed JSON
# and must store incomplete JSON returns as well as complete ones."""
# jsonResponse = ndb.TextProperty()
class NetworkResult(ResultObject):
"""The properties of a device's connection to the network,
either cellular or wifi."""
connectionType = ndb.StringProperty()
carrierName = ndb.StringProperty()
cellID = ndb.StringProperty()
class LocationResult(ResultObject):
"""A location and time associated with a TestMaster.
There will be several location objects for each master test."""
location = ndb.GeoPtProperty()
class PingResult(ResultObject):
"""Holds the response time for a ping test."""
pingedURL = ndb.StringProperty()
pingTime = ndb.FloatProperty()
class ReferenceObject(ndb.Model):
"""An object with a 'True' version of the response for a single
endpoint request."""
server = ndb.StringProperty()
dataset = ndb.StringProperty()
name = ndb.StringProperty()
httpMethod = ndb.StringProperty()
returnType = ndb.StringProperty()
reference = ndb.TextProperty()
class Vector(ndb.Model):
"""An analysis data structure, the output of the Analyse() function.
For each EndpointResult, Analyse() considers the LocationResults,
NetworkResults and PingResults immediately before and after. The network
connection may improve or degrade, the ping time increase or decrease
and so forth. The aim being to illustrate the change in circumstances
through the test period.
N.B. We should prefer to show improvement in signal or response time
with positive numeric values and degradation with negative values.
Hence subtracting the later pingTime from the prior, but conversely
subtracting the prior networkClass from the later."""
test = ndb.StructuredProperty(TestEndpoint)
name = ndb.StringProperty()
startDateTime = ndb.DateTimeProperty()
finishDateTime = ndb.DateTimeProperty()
responseTime = ndb.FloatProperty()
deviceType = ndb.StringProperty()
deviceID = ndb.StringProperty()
iOSVersion = ndb.StringProperty()
server = ndb.StringProperty()
dataset = ndb.StringProperty()
httpMethod = ndb.StringProperty()
returnType = ndb.StringProperty()
responseCode = ndb.IntegerProperty()
onDeviceSuccess = ndb.BooleanProperty()
referenceCheckSuccess = ndb.BooleanProperty()
referenceCheckValid = ndb.BooleanProperty(default=True)
preTestLocation = ndb.StructuredProperty(LocationResult)
postTestLocation = ndb.StructuredProperty(LocationResult)
preTestNetwork = ndb.StructuredProperty(NetworkResult)
postTestNetwork = ndb.StructuredProperty(NetworkResult)
preTestPing = ndb.StructuredProperty(PingResult)
postTestPing = ndb.StructuredProperty(PingResult)
distance = ndb.FloatProperty()
speed = ndb.FloatProperty()
pingChange = ndb.FloatProperty()
networkChange = ndb.FloatProperty()
class CampaignStats(ndb.Model):
"""A stored record of descriptive statistics for all tests in a
campaign. Updated when a test is analysed and stored for quick retrieval."""
campaignName = ndb.StringProperty()
countTestMasters = ndb.IntegerProperty()
allDeviceTypes = ndb.StringProperty()
allOSVersions = ndb.StringProperty()
countTestEndpoints = ndb.IntegerProperty()
totalTestEndpointTime = ndb.FloatProperty()
countTestEndpointsSuccessful = ndb.IntegerProperty()
countNetworkResults = ndb.IntegerProperty()
countLocationResults = ndb.IntegerProperty()
countPingResults = ndb.IntegerProperty()
countPingResultsSuccessful = ndb.IntegerProperty()
totalPingTime = ndb.FloatProperty()
ESRI_BusStops_AttributeFilter_GET_JSON = ndb.IntegerProperty()
ESRI_BusStops_AttributeFilter_POST_JSON = ndb.IntegerProperty()
ESRI_BusStops_Big_GET_JSON = ndb.IntegerProperty()
ESRI_BusStops_Big_POST_JSON = ndb.IntegerProperty()
ESRI_BusStops_FeatureByID_GET_JSON = ndb.IntegerProperty()
ESRI_BusStops_FeatureByID_POST_JSON = ndb.IntegerProperty()
ESRI_BusStops_GetCapabilities_GET_JSON = ndb.IntegerProperty()
ESRI_BusStops_GetCapabilities_POST_JSON = ndb.IntegerProperty()
ESRI_BusStops_IntersectFilter_GET_JSON = ndb.IntegerProperty()
ESRI_BusStops_IntersectFilter_POST_JSON = ndb.IntegerProperty()
ESRI_BusStops_Small_GET_JSON = ndb.IntegerProperty()
ESRI_BusStops_Small_POST_JSON = ndb.IntegerProperty()
ESRI_Topo_Big_POST_Image = ndb.IntegerProperty()
ESRI_Topo_Small_GET_Image = ndb.IntegerProperty()
ESRI_Topo_Small_POST_Image = ndb.IntegerProperty()
GME_AerialPhoto_Big_GET_Image = ndb.IntegerProperty()
GME_AerialPhoto_GetTileKVP_GET_Image = ndb.IntegerProperty()
GME_AerialPhoto_GetTileKVP2_GET_Image = ndb.IntegerProperty()
GME_AerialPhoto_GetTileKVP3_GET_Image = ndb.IntegerProperty()
GME_AerialPhoto_GetTileKVP4_GET_Image = ndb.IntegerProperty()
GME_AerialPhoto_Small_GET_Image = ndb.IntegerProperty()
GME_AerialPhoto_WMSGetCapabilities_GET_XML = ndb.IntegerProperty()
GME_AerialPhoto_WMTSGetCapabilities_GET_XML = ndb.IntegerProperty()
GME_BusStops_AttributeFilter_GET_JSON = ndb.IntegerProperty()
GME_BusStops_Big_GET_JSON = ndb.IntegerProperty()
GME_BusStops_DistanceFilter_GET_JSON = ndb.IntegerProperty()
GME_BusStops_FeatureByID_GET_JSON = ndb.IntegerProperty()
GME_BusStops_IntersectFilter_GET_JSON = ndb.IntegerProperty()
GME_BusStops_Small_GET_JSON = ndb.IntegerProperty()
OGC_AerialPhoto_GetTileKVP_GET_Image = ndb.IntegerProperty()
OGC_AerialPhoto_GetTileRestful_GET_Image = ndb.IntegerProperty()
OGC_BusStops_AttributeFilter_GET_JSON = ndb.IntegerProperty()
OGC_BusStops_AttributeFilter_GET_XML = ndb.IntegerProperty()
OGC_BusStops_AttributeFilter_POST_JSON = ndb.IntegerProperty()
OGC_BusStops_AttributeFilter_POST_XML = ndb.IntegerProperty()
OGC_BusStops_Big_GET_JSON = ndb.IntegerProperty()
OGC_BusStops_Big_GET_XML = ndb.IntegerProperty()
OGC_BusStops_Big_POST_JSON = ndb.IntegerProperty()
OGC_BusStops_Big_POST_XML = ndb.IntegerProperty()
OGC_BusStops_FeatureByID_GET_JSON = ndb.IntegerProperty()
OGC_BusStops_FeatureByID_GET_XML = ndb.IntegerProperty()
OGC_BusStops_FeatureByID_POST_JSON = ndb.IntegerProperty()
OGC_BusStops_FeatureByID_POST_XML = ndb.IntegerProperty()
OGC_BusStops_GetCapabilities_GET_XML = ndb.IntegerProperty()
OGC_BusStops_GetCapabilities_POST_XML = ndb.IntegerProperty()
OGC_BusStops_IntersectFilter_GET_JSON = ndb.IntegerProperty()
OGC_BusStops_IntersectFilter_GET_XML = ndb.IntegerProperty()
OGC_BusStops_IntersectFilter_POST_JSON = ndb.IntegerProperty()
OGC_BusStops_IntersectFilter_POST_XML = ndb.IntegerProperty()
OGC_BusStops_Small_GET_JSON = ndb.IntegerProperty()
OGC_BusStops_Small_GET_XML = ndb.IntegerProperty()
OGC_BusStops_Small_POST_JSON = ndb.IntegerProperty()
OGC_BusStops_Small_POST_XML = ndb.IntegerProperty()
OGC_Topo_Big_GET_Image = ndb.IntegerProperty()
OGC_Topo_Small_GET_Image = ndb.IntegerProperty()
ESRI_BusStops_AttributeFilter_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_BusStops_AttributeFilter_POST_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_BusStops_Big_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_BusStops_Big_POST_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_BusStops_FeatureByID_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_BusStops_FeatureByID_POST_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_BusStops_GetCapabilities_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_BusStops_GetCapabilities_POST_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_BusStops_IntersectFilter_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_BusStops_IntersectFilter_POST_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_BusStops_Small_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_BusStops_Small_POST_JSON_ReferenceSuccess = ndb.IntegerProperty()
ESRI_Topo_Big_POST_Image_ReferenceSuccess = ndb.IntegerProperty()
ESRI_Topo_Small_GET_Image_ReferenceSuccess = ndb.IntegerProperty()
ESRI_Topo_Small_POST_Image_ReferenceSuccess = ndb.IntegerProperty()
GME_AerialPhoto_Big_GET_Image_ReferenceSuccess = ndb.IntegerProperty()
GME_AerialPhoto_GetTileKVP_GET_Image_ReferenceSuccess = ndb.IntegerProperty()
GME_AerialPhoto_GetTileKVP2_GET_Image_ReferenceSuccess = ndb.IntegerProperty()
GME_AerialPhoto_GetTileKVP3_GET_Image_ReferenceSuccess = ndb.IntegerProperty()
GME_AerialPhoto_GetTileKVP4_GET_Image_ReferenceSuccess = ndb.IntegerProperty()
GME_AerialPhoto_Small_GET_Image_ReferenceSuccess = ndb.IntegerProperty()
GME_AerialPhoto_WMSGetCapabilities_GET_XML_ReferenceSuccess = ndb.IntegerProperty()
GME_AerialPhoto_WMTSGetCapabilities_GET_XML_ReferenceSuccess = ndb.IntegerProperty()
GME_BusStops_AttributeFilter_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
GME_BusStops_Big_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
GME_BusStops_DistanceFilter_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
GME_BusStops_FeatureByID_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
GME_BusStops_IntersectFilter_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
GME_BusStops_Small_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
OGC_AerialPhoto_GetTileKVP_GET_Image_ReferenceSuccess = ndb.IntegerProperty()
OGC_AerialPhoto_GetTileRestful_GET_Image_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_AttributeFilter_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_AttributeFilter_GET_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_AttributeFilter_POST_JSON_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_AttributeFilter_POST_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_Big_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_Big_GET_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_Big_POST_JSON_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_Big_POST_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_FeatureByID_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_FeatureByID_GET_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_FeatureByID_POST_JSON_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_FeatureByID_POST_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_GetCapabilities_GET_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_GetCapabilities_POST_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_IntersectFilter_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_IntersectFilter_GET_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_IntersectFilter_POST_JSON_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_IntersectFilter_POST_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_Small_GET_JSON_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_Small_GET_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_Small_POST_JSON_ReferenceSuccess = ndb.IntegerProperty()
OGC_BusStops_Small_POST_XML_ReferenceSuccess = ndb.IntegerProperty()
OGC_Topo_Big_GET_Image_ReferenceSuccess = ndb.IntegerProperty()
OGC_Topo_Small_GET_Image_ReferenceSuccess = ndb.IntegerProperty()