alfraser commited on
Commit
c76e6f5
·
1 Parent(s): e912278

Refactored loading the TestGroups to make the structure of the json load and the DB load the same and clearer

Browse files
Files changed (1) hide show
  1. 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 load_db_records(cls) -> List[TestGroup]:
 
 
 
 
 
 
 
 
 
 
 
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
- ArchitectureRequestRecord.load_all(reload=reload)
248
- records = {}
249
- for arr in ArchitectureRequestRecord.all:
250
- if arr.test_group is not None:
251
- if arr.test_group not in records:
252
- records[arr.test_group] = TestGroup(arr.test_group)
253
- records[arr.test_group].add_record(arr)
254
- db_records = cls.load_db_records()
255
- for test_group in db_records:
256
- records[test_group.test_group] = test_group
257
- cls.all = records
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: