@@ -51,3 +51,26 @@ def test_copy_ecu_without_frames():
51
51
assert len (matrix1 .frames ) == 1
52
52
assert len (matrix1 .ecus ) == 1
53
53
assert matrix1 .ecu_by_name ("ECU" ) is not None
54
+
55
+
56
+ def test_copy_ecu_with_attributes ():
57
+ matrix1 = canmatrix .canmatrix .CanMatrix ()
58
+ frame1 = canmatrix .canmatrix .Frame ("Frame1" , arbitration_id = 1 )
59
+ frame1 .add_signal (canmatrix .canmatrix .Signal ("SomeSignal" ))
60
+ matrix1 .add_frame (frame1 )
61
+
62
+ matrix2 = canmatrix .canmatrix .CanMatrix ()
63
+ frame2 = canmatrix .canmatrix .Frame ("Frame2" , arbitration_id = 2 , transmitters = ["ECU" ])
64
+ matrix2 .add_frame (frame2 )
65
+ matrix2 .update_ecu_list ()
66
+ matrix2 .add_ecu_defines ("Node Address" , "INT 0 255" )
67
+ matrix2 .add_ecu_defines ("attrib" , "STRING" )
68
+ matrix2 .ecu_by_name ("ECU" ).add_attribute ("attrib" , "attribValue" )
69
+ matrix2 .ecu_by_name ("ECU" ).add_attribute ("Node Address" , 42 )
70
+
71
+ canmatrix .copy .copy_ecu ("ECU" , matrix2 , matrix1 )
72
+
73
+ assert len (matrix1 .frames ) == 1
74
+ assert len (matrix1 .ecus ) == 1
75
+ assert matrix1 .ecu_by_name ("ECU" ) is not None
76
+ assert matrix1 .ecu_by_name ("ECU" ).attribute ("Node Address" ) == 42
0 commit comments