2121from BlockServerToKafka .block_server_monitor import BlockServerMonitor
2222
2323
24- @patch ("CaChannel.CaChannel" )
2524class TestBlockServerMonitor (unittest .TestCase ):
2625 test_address = "TEST_ADDRESS"
2726 test_prefix = "TEST_PREFIX"
2827
29- def setUp (self ):
28+ @patch ("CaChannel.CaChannel" )
29+ @patch ("CaChannel.CaChannel.searchw" )
30+ @patch ("CaChannel.CaChannel.add_masked_array_event" )
31+ @patch ("CaChannel.CaChannel.field_type" )
32+ @patch ("CaChannel.CaChannel.pend_event" )
33+ def setUp (self , * args , ** kwargs ):
3034 self .mock_producer = MagicMock ()
3135 self .bs_monitor = BlockServerMonitor (
3236 self .test_address , self .test_prefix , self .mock_producer
3337 )
3438
3539 def test_WHEN_convert_one_char_to_string_THEN_returns_character (
3640 self ,
37- mock_ca_channel ,
3841 ):
3942 c = "a"
4043 arr = [ord (c )]
4144 self .assertEqual (c , self .bs_monitor .convert_to_string (bytearray (arr )))
4245
43- def test_WHEN_convert_many_chars_to_string_THEN_returns_characters (self , mock_ca_channel ):
46+ def test_WHEN_convert_many_chars_to_string_THEN_returns_characters (self ):
4447 chars = "hello world"
4548 arr = [ord (c ) for c in chars ]
4649 self .assertEqual (chars , self .bs_monitor .convert_to_string (bytearray (arr )))
4750
4851 def test_WHEN_convert_chars_with_null_at_end_THEN_nulls_removed (
4952 self ,
50- mock_ca_channel ,
5153 ):
5254 chars = "hello world"
5355 arr = [ord (c ) for c in chars ]
@@ -57,35 +59,31 @@ def test_WHEN_convert_chars_with_null_at_end_THEN_nulls_removed(
5759
5860 def test_WHEN_convert_chars_with_null_at_start_THEN_nulls_removed (
5961 self ,
60- mock_ca_channel ,
6162 ):
6263 chars = "hello world"
6364 arr = [ord (c ) for c in chars ]
6465 for i in range (3 ):
6566 arr .insert (0 , 0 )
6667 self .assertEqual (chars , self .bs_monitor .convert_to_string (bytearray (arr )))
6768
68- def test_WHEN_convert_chars_with_nulls_in_centre_THEN_nulls_removed (self , mock_ca_channel ):
69+ def test_WHEN_convert_chars_with_nulls_in_centre_THEN_nulls_removed (self ):
6970 chars = "hello world"
7071 arr = [ord (c ) for c in chars ]
7172 arr .insert (4 , 0 )
7273 self .assertEqual (chars , self .bs_monitor .convert_to_string (bytearray (arr )))
7374
7475 def test_WHEN_convert_nulls_THEN_empty_string_returned (
7576 self ,
76- mock_ca_channel ,
7777 ):
7878 arr = [0 ] * 10
7979 self .assertEqual ("" , self .bs_monitor .convert_to_string (bytearray (arr )))
8080
81- def test_GIVEN_no_previous_pvs_WHEN_update_config_called_THEN_producer_is_called (
82- self , mock_ca_channel
83- ):
81+ def test_GIVEN_no_previous_pvs_WHEN_update_config_called_THEN_producer_is_called (self ):
8482 self .bs_monitor .update_config (["BLOCK" ])
8583 self .mock_producer .add_config .assert_called_once ()
8684
8785 def test_GIVEN_no_previous_pvs_WHEN_update_config_called_THEN_producer_is_called_containing_block_name (
88- self , mock_ca_channel
86+ self ,
8987 ):
9088 block = "BLOCK"
9189 self .bs_monitor .update_config ([block ])
@@ -94,15 +92,15 @@ def test_GIVEN_no_previous_pvs_WHEN_update_config_called_THEN_producer_is_called
9492 )
9593
9694 def test_GIVEN_previous_pvs_WHEN_update_config_called_with_same_pvs_THEN_producer_is_not_called (
97- self , mock_ca_channel
95+ self ,
9896 ):
9997 block = "BLOCK"
10098 self .bs_monitor .update_config ([block ])
10199 self .bs_monitor .update_config ([block ])
102100 self .mock_producer .add_config .assert_called_once ()
103101
104102 def test_GIVEN_previous_pvs_WHEN_update_config_called_with_different_pvs_THEN_producer_is_called (
105- self , mock_ca_channel
103+ self ,
106104 ):
107105 self .bs_monitor .update_config (["OLD_BLOCK" ])
108106 self .mock_producer .reset_mock ()
0 commit comments