def test_PowerMulti_calls_targets_off_methods(): num_mock_powers = 3 mock_powers = [MockPower() for __ in range(0, num_mock_powers)] power = PowerMulti(power_seq=mock_powers) power.off() assert (all([mp.off_called == 1 for mp in mock_powers]))
def test_PowerMulti_calls_targets_on_methods_in_correct_order(): mocks_on_list = [] num_mock_powers = 3 mock_powers = [ MockPower(mocks_on_list=mocks_on_list) for __ in range(0, num_mock_powers) ] power = PowerMulti(power_seq=mock_powers) power.on() assert (mock_powers == mocks_on_list)
def test_PowerMulti_calls_targets_off_methods_in_reverse_order_with_reverse_off_seq_default( ): mocks_off_list = [] num_mock_powers = 3 mock_powers = [ MockPower(mocks_off_list=mocks_off_list) for __ in range(0, num_mock_powers) ] power = PowerMulti(power_seq=mock_powers) power.off() assert (mock_powers[::-1] == mocks_off_list)
def test_PowerMulti_calls_targets_off_methods_in_sequence_order_with_reverse_off_seq_false( ): mocks_off_list = [] num_mock_powers = 3 mock_powers = [ MockPower(mocks_off_list=mocks_off_list) for __ in range(0, num_mock_powers) ] power = PowerMulti(power_seq=mock_powers, reverse_off_seq=False) power.off() assert (mock_powers == mocks_off_list)