|
1 | | -all_analytics_query = ''' |
| 1 | +import datetime |
| 2 | +from helpers.calendar.all_analytics_helper import AllAnalyticsHelper |
| 3 | + |
| 4 | +last_seen = datetime.datetime.strptime( |
| 5 | + "2019-04-10 13:28:45.394782", "%Y-%m-%d %H:%M:%S.%f" |
| 6 | +) |
| 7 | +downtime_value = AllAnalyticsHelper.convert_to_human_readable(last_seen) |
| 8 | + |
| 9 | +all_analytics_query = """ |
2 | 10 | query { |
3 | 11 | allAnalytics(startDate:"jul 11 2018", endDate:"jul 12 2018", locationId:1) { # noqa: E501 |
4 | 12 | checkinsPercentage |
|
25 | 33 | totalBookings |
26 | 34 | period |
27 | 35 | } |
| 36 | + deviceAnalytics{ |
| 37 | + deviceName |
| 38 | + deviceId |
| 39 | + downTime |
| 40 | + } |
28 | 41 | } |
29 | 42 | } |
30 | | -''' |
31 | | -all_analytics_query_invalid_locationid = ''' |
| 43 | +""" |
| 44 | +all_analytics_query_invalid_locationid = """ |
32 | 45 | query { |
33 | 46 | allAnalytics(startDate:"jul 11 2018", endDate:"jul 12 2018", locationId:10) { # noqa: E501 |
34 | 47 | checkinsPercentage |
|
57 | 70 | } |
58 | 71 | } |
59 | 72 | } |
60 | | -''' |
| 73 | +""" |
61 | 74 |
|
62 | 75 | all_analytics_query_response = { |
63 | | - "data": { |
64 | | - "allAnalytics": { |
65 | | - "checkinsPercentage": 0.0, |
66 | | - "appBookingsPercentage": 0.0, |
67 | | - "autoCancellationsPercentage": 0.0, |
68 | | - "cancellationsPercentage": 0.0, |
69 | | - "bookings": 1, |
70 | | - "analytics": [ |
71 | | - { |
72 | | - "roomName": "Entebbe", |
73 | | - "cancellations": 0, |
74 | | - "cancellationsPercentage": 0.0, |
75 | | - "autoCancellations": 0, |
76 | | - "numberOfBookings": 1, |
77 | | - "checkins": 0, |
78 | | - "checkinsPercentage": 0.0, |
79 | | - "bookingsPercentageShare": 100.0, |
80 | | - "appBookings": 0, |
81 | | - "appBookingsPercentage": 0.0, |
82 | | - "events": [ |
83 | | - { |
84 | | - "durationInMinutes": 45 |
85 | | - } |
86 | | - ] |
87 | | - }, |
88 | | - { |
89 | | - "roomName": "Tana", |
90 | | - "cancellations": 0, |
91 | | - "cancellationsPercentage": 0.0, |
92 | | - "autoCancellations": 0, |
93 | | - "numberOfBookings": 0, |
94 | | - "checkins": 0, |
95 | | - "checkinsPercentage": 0.0, |
96 | | - "bookingsPercentageShare": 0.0, |
97 | | - "appBookings": 0, |
98 | | - "appBookingsPercentage": 0.0, |
99 | | - "events": [ |
100 | | - { |
101 | | - "durationInMinutes": 0 |
102 | | - } |
103 | | - ] |
104 | | - } |
105 | | - ], |
106 | | - "bookingsCount": [ |
107 | | - { |
108 | | - "totalBookings": 1, |
109 | | - "period": "Jul 11 2018" |
110 | | - }, |
111 | | - { |
112 | | - 'totalBookings': 0, |
113 | | - 'period': 'Jul 12 2018' |
| 76 | + "data": { |
| 77 | + "allAnalytics": { |
| 78 | + "checkinsPercentage": 0.0, |
| 79 | + "appBookingsPercentage": 0.0, |
| 80 | + "autoCancellationsPercentage": 0.0, |
| 81 | + "cancellationsPercentage": 0.0, |
| 82 | + "bookings": 1, |
| 83 | + "analytics": [ |
| 84 | + { |
| 85 | + "roomName": "Entebbe", |
| 86 | + "cancellations": 0, |
| 87 | + "cancellationsPercentage": 0.0, |
| 88 | + "autoCancellations": 0, |
| 89 | + "numberOfBookings": 1, |
| 90 | + "checkins": 0, |
| 91 | + "checkinsPercentage": 0.0, |
| 92 | + "bookingsPercentageShare": 100.0, |
| 93 | + "appBookings": 0, |
| 94 | + "appBookingsPercentage": 0.0, |
| 95 | + "events": [{"durationInMinutes": 45}], |
| 96 | + }, |
| 97 | + { |
| 98 | + "roomName": "Tana", |
| 99 | + "cancellations": 0, |
| 100 | + "cancellationsPercentage": 0.0, |
| 101 | + "autoCancellations": 0, |
| 102 | + "numberOfBookings": 0, |
| 103 | + "checkins": 0, |
| 104 | + "checkinsPercentage": 0.0, |
| 105 | + "bookingsPercentageShare": 0.0, |
| 106 | + "appBookings": 0, |
| 107 | + "appBookingsPercentage": 0.0, |
| 108 | + "events": [{"durationInMinutes": 0}], |
| 109 | + }, |
| 110 | + ], |
| 111 | + "bookingsCount": [ |
| 112 | + {"totalBookings": 1, "period": "Jul 11 2018"}, |
| 113 | + {"totalBookings": 0, "period": "Jul 12 2018"}, |
| 114 | + ], |
| 115 | + "deviceAnalytics": [ |
| 116 | + { |
| 117 | + "deviceName": "Samsung", |
| 118 | + "deviceId": 1, |
| 119 | + "downTime": "this device was seen {}".format( |
| 120 | + downtime_value), |
| 121 | + } |
| 122 | + ], |
114 | 123 | } |
115 | | - ] |
116 | 124 | } |
117 | | - } |
118 | 125 | } |
119 | 126 |
|
120 | 127 | all_analytics_query_response_super_admin_with_invalid_locationid = { |
121 | 128 | "errors": [ |
122 | 129 | { |
123 | 130 | "message": "Location Id does not exist", |
124 | | - "locations": [ |
125 | | - { |
126 | | - "line": 3, |
127 | | - "column": 7 |
128 | | - } |
129 | | - ], |
130 | | - "path": [ |
131 | | - "allAnalytics" |
132 | | - ] |
| 131 | + "locations": [{"line": 3, "column": 7}], |
| 132 | + "path": ["allAnalytics"], |
133 | 133 | } |
134 | 134 | ], |
135 | | - "data": { |
136 | | - "allAnalytics": None |
137 | | - } |
| 135 | + "data": {"allAnalytics": None}, |
138 | 136 | } |
139 | 137 |
|
140 | 138 | all_analytics_query_response_super_admin = { |
|
157 | 155 | "bookingsPercentageShare": 50.0, |
158 | 156 | "appBookings": 0, |
159 | 157 | "appBookingsPercentage": 0.0, |
160 | | - "events": [ |
161 | | - { |
162 | | - "durationInMinutes": 890 |
163 | | - } |
164 | | - ] |
| 158 | + "events": [{"durationInMinutes": 890}], |
165 | 159 | }, |
166 | 160 | { |
167 | 161 | "roomName": "Krypton", |
|
174 | 168 | "bookingsPercentageShare": 25.0, |
175 | 169 | "appBookings": 0, |
176 | 170 | "appBookingsPercentage": 0.0, |
177 | | - "events": [ |
178 | | - { |
179 | | - "durationInMinutes": 155 |
180 | | - } |
181 | | - ] |
| 171 | + "events": [{"durationInMinutes": 155}], |
182 | 172 | }, |
183 | 173 | { |
184 | 174 | "roomName": "Bujumbura", |
|
191 | 181 | "bookingsPercentageShare": 25.0, |
192 | 182 | "appBookings": 0, |
193 | 183 | "appBookingsPercentage": 0.0, |
194 | | - "events": [ |
195 | | - { |
196 | | - "durationInMinutes": 92 |
197 | | - } |
198 | | - ] |
| 184 | + "events": [{"durationInMinutes": 92}], |
199 | 185 | }, |
200 | 186 | { |
201 | 187 | "roomName": "Kampala", |
|
208 | 194 | "bookingsPercentageShare": 0.0, |
209 | 195 | "appBookings": 0, |
210 | 196 | "appBookingsPercentage": 0.0, |
211 | | - "events": [ |
212 | | - { |
213 | | - "durationInMinutes": 0 |
214 | | - } |
215 | | - ] |
| 197 | + "events": [{"durationInMinutes": 0}], |
216 | 198 | }, |
217 | 199 | { |
218 | 200 | "roomName": "Algiers", |
|
225 | 207 | "bookingsPercentageShare": 0.0, |
226 | 208 | "appBookings": 0, |
227 | 209 | "appBookingsPercentage": 0.0, |
228 | | - "events": [ |
229 | | - { |
230 | | - "durationInMinutes": 0 |
231 | | - } |
232 | | - ] |
233 | | - } |
| 210 | + "events": [{"durationInMinutes": 0}], |
| 211 | + }, |
234 | 212 | ], |
235 | 213 | "bookingsCount": [ |
236 | | - { |
237 | | - "totalBookings": 7, |
238 | | - "period": "Jul 11 2018" |
239 | | - }, |
240 | | - { |
241 | | - "totalBookings": 5, |
242 | | - "period": "Jul 12 2018" |
243 | | - } |
244 | | - ] |
| 214 | + {"totalBookings": 7, "period": "Jul 11 2018"}, |
| 215 | + {"totalBookings": 5, "period": "Jul 12 2018"}, |
| 216 | + ], |
245 | 217 | } |
246 | 218 | } |
247 | 219 | } |
248 | 220 |
|
249 | | -analytics_query_for_date_ranges = ''' |
| 221 | +analytics_query_for_date_ranges = """ |
250 | 222 | query { |
251 | 223 | allAnalytics(startDate:"jul 11 2020", endDate:"jul 12 2018") { |
252 | 224 | checkinsPercentage |
|
275 | 247 | } |
276 | 248 | } |
277 | 249 | } |
278 | | -''' |
| 250 | +""" |
0 commit comments