Spaces:
Runtime error
Runtime error
Refactored loading the TestGroups to make the structure of the json load and the DB load the same and clearer
Browse files- src/testing.py +24 -13
src/testing.py
CHANGED
@@ -210,7 +210,18 @@ class TestGroup:
|
|
210 |
self.elapsed = self.end - self.start
|
211 |
|
212 |
@classmethod
|
213 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
"""
|
215 |
Load all the test groups from the DataBase
|
216 |
"""
|
@@ -238,23 +249,23 @@ class TestGroup:
|
|
238 |
return test_groups
|
239 |
|
240 |
@classmethod
|
241 |
-
def load_all(cls, reload=False):
|
242 |
"""
|
243 |
Load all the available TestGroups, from both the json file and the DB
|
244 |
into the class variable - for efficiency do not reload unless requested
|
245 |
"""
|
246 |
if cls.all is None or reload:
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
cls.all =
|
258 |
|
259 |
@classmethod
|
260 |
def for_test_group_tag(cls, test_group_tag: str) -> TestGroup:
|
|
|
210 |
self.elapsed = self.end - self.start
|
211 |
|
212 |
@classmethod
|
213 |
+
def load_json_test_groups(cls, reload: bool = False) -> List[TestGroup]:
|
214 |
+
ArchitectureRequestRecord.load_all(reload=reload)
|
215 |
+
test_groups: Dict[str, TestGroup] = {}
|
216 |
+
for arr in ArchitectureRequestRecord.all:
|
217 |
+
if arr.test_group is not None:
|
218 |
+
if arr.test_group not in test_groups:
|
219 |
+
test_groups[arr.test_group] = TestGroup(arr.test_group)
|
220 |
+
test_groups[arr.test_group].add_record(arr)
|
221 |
+
return list(test_groups.values())
|
222 |
+
|
223 |
+
@classmethod
|
224 |
+
def load_db_test_groups(cls) -> List[TestGroup]:
|
225 |
"""
|
226 |
Load all the test groups from the DataBase
|
227 |
"""
|
|
|
249 |
return test_groups
|
250 |
|
251 |
@classmethod
|
252 |
+
def load_all(cls, reload: bool = False):
|
253 |
"""
|
254 |
Load all the available TestGroups, from both the json file and the DB
|
255 |
into the class variable - for efficiency do not reload unless requested
|
256 |
"""
|
257 |
if cls.all is None or reload:
|
258 |
+
working_test_groups = {}
|
259 |
+
|
260 |
+
json_tgs = cls.load_json_test_groups(reload=reload)
|
261 |
+
for test_group in json_tgs:
|
262 |
+
working_test_groups[test_group.test_group] = test_group
|
263 |
+
|
264 |
+
db_tgs = cls.load_db_test_groups()
|
265 |
+
for test_group in db_tgs:
|
266 |
+
working_test_groups[test_group.test_group] = test_group
|
267 |
+
|
268 |
+
cls.all = working_test_groups
|
269 |
|
270 |
@classmethod
|
271 |
def for_test_group_tag(cls, test_group_tag: str) -> TestGroup:
|