Exemplo n.º 1
0
def test_enumerate_xnet_devices_prints_device_info_when_xnet_devices_are_present_under_chassis(session_mock, stdout_mock):
    session_mock.insert_device_to_chassis()
    utilities.enumerate_xnet_devices()
    assert 'My System:\n' in stdout_mock.getvalue()
    assert _sysapi_data['chassis1_mock']['expert_user_alias'][0] in stdout_mock.getvalue()
    assert _sysapi_data['device1_mock']['product_name'] in stdout_mock.getvalue()
    assert _sysapi_data['device1_port1_mock']['expert_user_alias'][0] in stdout_mock.getvalue()
Exemplo n.º 2
0
def main(argv=sys.argv[1:]):
    args = parse_args(argv)
    configure_logger(args)

    try:
        args.command(**get_command_arguments(args))

        if args.enumerate:
            utilities.enumerate_xnet_devices()

    except utilities.XnetConfigError as err:
        logger.error(err.message, exc_info=(logger.getEffectiveLevel() == logging.DEBUG))
        sys.exit(1)

    except Exception:
        logger.error('Operation failed', exc_info=(logger.getEffectiveLevel() == logging.DEBUG))
        sys.exit(1)
Exemplo n.º 3
0
def test_enumerate_xnet_devices_prints_device_info_when_xnet_devices_has_no_firmware_version(session_mock, stdout_mock):
    session_mock.update_device_firmware_version('')
    utilities.enumerate_xnet_devices()
    assert 'My System:\n' in stdout_mock.getvalue()
    assert _sysapi_data['device1_mock']['product_name'] in stdout_mock.getvalue()
    assert _sysapi_data['device1_port1_mock']['expert_user_alias'][0] in stdout_mock.getvalue()
Exemplo n.º 4
0
def test_enumerate_xnet_devices_prints_only_my_system_when_no_xnet_devices_are_present(session_mock, stdout_mock):
    utilities.enumerate_xnet_devices()
    assert stdout_mock.getvalue() == 'My System:\n'