def test_TargetFactory_SoftPower_parameters_can_be_specified(mock_console):
    on_cmd = 'foo'
    off_cmd = 'bar'
    reboot_delay = 42

    config = Configuration({
        'soft': {
            'on_cmd': on_cmd,
            'off_cmd': off_cmd,
            'reboot_delay': reboot_delay
        }
    })
    power = TargetFactory.create_power_control(config, mock_console)

    assert isinstance(power, SoftPower)
    assert power.on_cmd == on_cmd
    assert power.off_cmd == off_cmd
    assert power.reboot_delay == reboot_delay
def test_TargetFactory_create_power_control_should_create_ipp9258(
        mock_console):
    host = 'hosttest'
    outlet = 3
    login = '******'
    password = '******'

    ipp_config = Configuration({
        'ippower9258': {
            'host': host,
            'outlet': outlet,
            'login': login,
            'password': password
        }
    })

    power = TargetFactory.create_power_control(ipp_config, mock_console)
    assert isinstance(power, IPPowerPDU)
    assert power.host == host
    assert power.port == outlet
    assert power.username == login
    assert power.password == password
def test_TargetFactory_create_power_control_should_default_to_SoftPower(
        mock_console):
    power = TargetFactory.create_power_control(None, mock_console)
    assert isinstance(power, SoftPower)
def test_TargetFactory_create_power_control_should_return_none_with_no_console(
):
    power = TargetFactory.create_power_control(power_config=None, console=None)
    assert power is None