@@ -38,6 +38,66 @@ def test_tally_display_conversion(faker):
38
38
assert disp == Display .from_tally (tally ) == tally
39
39
assert Tally .from_display (disp ).normalized_brightness == tally .normalized_brightness
40
40
41
+ def test_color_merge ():
42
+ t1 = Tally (0 )
43
+
44
+ t1 .set_color (TallyType .rh_tally | TallyType .lh_tally , TallyColor .RED )
45
+ assert t1 .rh_tally == TallyColor .RED
46
+ assert t1 .txt_tally == TallyColor .OFF
47
+ assert t1 .lh_tally == TallyColor .RED
48
+
49
+ t1 .set_color (TallyType .rh_tally | TallyType .lh_tally , TallyColor .GREEN )
50
+ assert t1 .rh_tally == TallyColor .GREEN
51
+ assert t1 .txt_tally == TallyColor .OFF
52
+ assert t1 .lh_tally == TallyColor .GREEN
53
+
54
+ t1 .merge_color (TallyType .all_tally , TallyColor .RED )
55
+ assert t1 .rh_tally == TallyColor .AMBER
56
+ assert t1 .txt_tally == TallyColor .RED
57
+ assert t1 .lh_tally == TallyColor .AMBER
58
+
59
+ t1 .merge_color (TallyType .all_tally , TallyColor .GREEN )
60
+ assert t1 .rh_tally == TallyColor .AMBER
61
+ assert t1 .txt_tally == TallyColor .AMBER
62
+ assert t1 .lh_tally == TallyColor .AMBER
63
+
64
+ # Reset t1 to OFF, OFF, RED
65
+ t1 .rh_tally = TallyColor .OFF
66
+ t1 .txt_tally = TallyColor .OFF
67
+ t1 .lh_tally = TallyColor .RED
68
+
69
+ # Another Tally with only `txt_tally` set
70
+ t2 = Tally (1 , txt_tally = TallyColor .GREEN )
71
+
72
+ # Only `txt_tally` should change
73
+ t1 .merge (t2 , TallyType .all_tally )
74
+ assert t1 .rh_tally == TallyColor .OFF
75
+ assert t1 .txt_tally == TallyColor .GREEN
76
+ assert t1 .lh_tally == TallyColor .RED
77
+
78
+ # Reset t2 to GREEN, RED, GREEN
79
+ # t1 is still OFF, GREEN, RED
80
+ t2 .rh_tally = TallyColor .GREEN
81
+ t2 .txt_tally = TallyColor .RED
82
+ t2 .lh_tally = TallyColor .GREEN
83
+
84
+ t1 .merge (t2 , TallyType .rh_tally | TallyType .lh_tally )
85
+ assert t1 .rh_tally == TallyColor .GREEN
86
+ assert t1 .txt_tally == TallyColor .GREEN
87
+ assert t1 .lh_tally == TallyColor .AMBER
88
+
89
+ t1 .merge (t2 , TallyType .all_tally )
90
+ assert t1 .rh_tally == TallyColor .GREEN
91
+ assert t1 .txt_tally == TallyColor .AMBER
92
+ assert t1 .lh_tally == TallyColor .AMBER
93
+
94
+ t2 .rh_tally = TallyColor .RED
95
+ t1 .merge (t2 , TallyType .all_tally )
96
+ assert t1 .rh_tally == TallyColor .AMBER
97
+ assert t1 .txt_tally == TallyColor .AMBER
98
+ assert t1 .lh_tally == TallyColor .AMBER
99
+
100
+
41
101
def test_broadcast (faker ):
42
102
for _ in range (1000 ):
43
103
i = faker .pyint (max_value = 0xfffe )
0 commit comments