@@ -23,7 +23,6 @@ STAGES = ["stable", "beta", "preview", "alpha"]
2323# stages to consider for a pass
2424
2525STAGES_FOR_PASS = ["stable" , "beta" ]
26- DEFAULT_SCORE = 1
2726REFERENCE_SEQUENCES_DIR = "validator/sequences"
2827CHECKMARK = "✓"
2928CROSS = "✕"
@@ -41,7 +40,13 @@ def first_occurence(iteratable: Iterable, predicate: Callable) -> int:
4140 raise ValueError ()
4241
4342
44- @dataclass (unsafe_hash = True , eq = True , order = True )
43+ def sanitize (string : str ):
44+ """Sanitize string for safe displaying"""
45+ sanitized = string .replace ("\n " , "; " )
46+ return sanitized
47+
48+
49+ @dataclass (kw_only = True ,unsafe_hash = True , eq = True , order = True )
4550class TestResult :
4651 """Container for test result."""
4752
@@ -51,7 +56,8 @@ class TestResult:
5156 result : str = ""
5257 stage : str = ""
5358 message : str = ""
54- score : int = DEFAULT_SCORE
59+ score : int = 0
60+ total : int = 0
5561
5662 def passed (self ):
5763 if self .result == "pass" :
@@ -272,17 +278,23 @@ class TemplateHelper:
272278
273279@dataclass
274280class FeatureStage :
275- """Container for scored points and total points for a feature and stage."""
281+ """Container for scored points and total points for a feature and stage.
282+
283+ Arguments:
284+ scored: Number of points scored for a given feature at a given stage.
285+ total: Total points which could possibly have attained.
286+ stage: The stage e.g. BETA, STABLE, etc.
287+ tests: List of tests for this feature at the given stage.
288+ """
276289
277290 scored : int = 0
278291 total : int = 0
279292 stage : str = ""
280293 tests : list = field (default_factory = list )
281294
282- def add (self , result , score ):
283- self .total += score
284- if result == "pass" :
285- self .scored += score
295+ def add (self , * , test_score :int , test_total :int ):
296+ self .total += test_total
297+ self .scored += test_score
286298
287299 def has (self ):
288300 """Did the sequencer results have this feature & stage combination?."""
@@ -394,6 +406,10 @@ class SequencerReport:
394406 self .site_path , "cloud_iot_config.json"
395407 )
396408
409+ self .gateway = (
410+ self .metadata .get ("gateway" , {}).get ("gateway_id" )
411+ )
412+
397413 def has_stage (self , stage : str ):
398414 """Checks if sequencer report has any tests at given stage."""
399415 all_features = [x [stage ] for x in self .features .values ()]
@@ -408,14 +424,17 @@ class SequencerReport:
408424 features [feature ] = copy .deepcopy (stages_template )
409425 for name , result in sequences ["sequences" ].items ():
410426 results [name ] = TestResult (
411- feature ,
412- name ,
413- result .get ("summary" , "" ),
414- result ["result" ],
415- result ["stage" ],
416- self .sanitize (result ["status" ]["message" ]),
427+ bucket = feature ,
428+ name = name ,
429+ description = result .get ("summary" , "" ),
430+ result = result ["result" ],
431+ stage = result ["stage" ],
432+ message = sanitize (result ["status" ]["message" ]),
433+ score = result ["scoring" ]["value" ],
434+ total = result ["scoring" ]["total" ],
417435 )
418- features [feature ][result ["stage" ]].add (result ["result" ], DEFAULT_SCORE )
436+
437+ features [feature ][result ["stage" ]].add (test_score = result ["scoring" ]["value" ], test_total = result ["scoring" ]["total" ])
419438 features [feature ][result ["stage" ]].tests .append (result )
420439
421440 self .results = {
@@ -444,11 +463,6 @@ class SequencerReport:
444463 for f in self .features
445464 }
446465
447- def sanitize (self , string : str ):
448- """Sanitize string for safe displaying"""
449- sanitized = string .replace ("\n " , ";" )
450- return sanitized
451-
452466 def __repr__ (self ):
453467 return str (self .results )
454468
0 commit comments