def test_exception():
    host_uuids = Mock()
    host_uuids.content = HOST_UUIDS_2.splitlines()
    qpid_queues = Mock()
    qpid_queues.content = QPID_QUEUES.splitlines()
    messages = Mock()
    messages.stream = mock_stream_without_error
    broker = {
        Specs.messages: messages,
        LocalSpecs.content_host_uuids: host_uuids,
        LocalSpecs.qpid_queues: qpid_queues,
    }
    with pytest.raises(SkipComponent):
        satellite_missed_pulp_agent_queues(broker)

    new_messages = Mock()
    new_messages.stream = mock_stream_with_queue_exists
    broker[Specs.messages] = new_messages
    with pytest.raises(SkipComponent):
        satellite_missed_pulp_agent_queues(broker)

    empty_uuids = Mock()
    empty_uuids.content = HOST_UUIDS_1.splitlines()
    broker[LocalSpecs.content_host_uuids] = empty_uuids
    with pytest.raises(SkipComponent):
        satellite_missed_pulp_agent_queues(broker)
Ejemplo n.º 2
0
def test_cloud_cfg_bad():
    cloud_init_file = Mock()
    cloud_init_file.content = CLOUD_CFG_BAD.splitlines()
    broker = {LocalSpecs.cloud_cfg_input: cloud_init_file}
    with pytest.raises(SkipComponent) as e:
        cloud_cfg(broker)
    assert 'Invalid YAML format' in str(e)

    cloud_init_file.content = CLOUD_CFG_BAD_INDENT.splitlines()
    broker = {LocalSpecs.cloud_cfg_input: cloud_init_file}
    with pytest.raises(SkipComponent) as e:
        cloud_cfg(broker)
    assert 'Unexpected exception' in str(e)
Ejemplo n.º 3
0
def test_ps_eo_cmd_empty():
    ps_eo_args = Mock()
    ps_eo_args.content = PS_EMPTY.splitlines()
    broker = {LocalSpecs.ps_eo_args: ps_eo_args}
    with pytest.raises(SkipComponent) as e:
        ps_eo_cmd(broker)
    assert e is not None
Ejemplo n.º 4
0
def test_cloud_cfg_no_network():
    cloud_init_file = Mock()
    cloud_init_file.content = CLOUD_CFG_NO_NETWORK.splitlines()
    broker = {LocalSpecs.cloud_cfg_input: cloud_init_file}
    with pytest.raises(SkipComponent) as e:
        cloud_cfg(broker)
    assert 'No network section in yaml' in str(e)
Ejemplo n.º 5
0
def test_lpstat_datasource_NG_output():
    lpstat_data = Mock()
    lpstat_data.content = LPSTAT_V_NOT_GOOD.splitlines()
    broker = {LocalSpecs.lpstat_v: lpstat_data}
    with pytest.raises(SkipComponent) as e:
        lpstat_protocol_printers_info(broker)
    assert 'SkipComponent' in str(e)
Ejemplo n.º 6
0
def test_ansible_tower_license_datasource_NG_output():
    awx_manage_data = Mock()
    awx_manage_data.content = NG_COMMAND.splitlines()
    broker = {LocalSpecs.awx_manage_check_license_data_raw: awx_manage_data}
    with pytest.raises(SkipComponent) as e:
        awx_manage_check_license_data_datasource(broker)
    assert 'Unexpected exception' in str(e)
Ejemplo n.º 7
0
def test_ansible_tower_license_datasource_no_filter():
    awx_manage_data = Mock()
    awx_manage_data.content = AWX_MANAGE_LICENSE.splitlines()
    broker = {LocalSpecs.awx_manage_check_license_data_raw: awx_manage_data}
    with pytest.raises(SkipComponent) as e:
        awx_manage_check_license_data_datasource(broker)
    assert 'SkipComponent' in str(e)
Ejemplo n.º 8
0
def test_candlepin_broker_bad():
    candlepin_broker_file = Mock()
    candlepin_broker_file.content = CANDLEPIN_BROKER_BAD.splitlines()
    broker = {candlepin_broker.LocalSpecs.candlepin_broker_input: candlepin_broker_file}
    with pytest.raises(SkipComponent) as e:
        candlepin_broker.candlepin_broker(broker)
    assert 'Unexpected exception' in str(e)
Ejemplo n.º 9
0
def test_cloud_cfg_no_filter():
    cloud_init_file = Mock()
    cloud_init_file.content = CLOUD_CFG.format(value=1).splitlines()
    broker = {LocalSpecs.cloud_cfg_input: cloud_init_file}
    with pytest.raises(SkipComponent) as e:
        cloud_cfg(broker)
    assert 'SkipComponent' in str(e)
Ejemplo n.º 10
0
def test_ethernet_interfaces():
    ip_link_command = Mock()
    ip_link_command.content = IP_LINK.splitlines()
    broker = {LocalSpecs.ip_link: ip_link_command}
    result = interfaces(broker)
    assert result is not None
    assert isinstance(result, list)
    assert result == sorted(EXPECTED)
Ejemplo n.º 11
0
def test_ansible_tower_license_datasource():
    awx_manage_data = Mock()
    awx_manage_data.content = AWX_MANAGE_LICENSE.splitlines()
    broker = {LocalSpecs.awx_manage_check_license_data_raw: awx_manage_data}
    result = awx_manage_check_license_data_datasource(broker)
    assert result is not None
    assert isinstance(result, DatasourceProvider)
    expected = DatasourceProvider(content=json.dumps(collections.OrderedDict(sorted(AWX_MANAGE_FILTER_JSON.items()))), relative_path=RELATIVE_PATH)
    assert result.content == expected.content
    assert result.relative_path == expected.relative_path
Ejemplo n.º 12
0
def test_semid():
    ipcs_command = Mock()
    ipcs_command.content = IPCS_OUTPUT1.splitlines()
    broker = {Specs.ipcs_s: ipcs_command}
    result = ipcs.semid(broker)
    assert result is not None
    assert isinstance(result, list)
    assert '65570' in result
    assert '98357' in result
    assert len(result) == 6
def test_satellite_missed_queues_with_more_data():
    host_uuids = Mock()
    host_uuids.content = HOST_UUIDS_2.splitlines()
    qpid_queues = Mock()
    qpid_queues.content = QPID_QUEUES.splitlines()
    messages = Mock()
    messages.stream = mock_stream
    broker = {
        Specs.messages: messages,
        LocalSpecs.content_host_uuids: host_uuids,
        LocalSpecs.qpid_queues: qpid_queues,
    }
    result = satellite_missed_pulp_agent_queues(broker)
    assert result is not None
    assert isinstance(result, DatasourceProvider)
    expected = DatasourceProvider(content=MISSED_QUEUES_OUTPUT_2.splitlines(),
                                  relative_path=RELATIVE_PATH)
    assert sorted(result.content) == sorted(expected.content)
    assert result.relative_path == expected.relative_path
Ejemplo n.º 14
0
def test_cloud_cfg():
    cloud_init_file = Mock()
    cloud_init_file.content = CLOUD_CFG.splitlines()
    broker = {LocalSpecs.cloud_cfg_input: cloud_init_file}
    result = cloud_cfg(broker)
    assert result is not None
    assert isinstance(result, DatasourceProvider)
    expected = DatasourceProvider(content=json.dumps(CLOUD_CFG_JSON), relative_path=RELATIVE_PATH)
    assert result.content == expected.content
    assert result.relative_path == expected.relative_path
Ejemplo n.º 15
0
def test_ps_eo_cmd():
    ps_eo_args = Mock()
    ps_eo_args.content = PS_DATA.splitlines()
    broker = {LocalSpecs.ps_eo_args: ps_eo_args}
    result = ps_eo_cmd(broker)
    assert result is not None
    assert isinstance(result, DatasourceProvider)
    expected = DatasourceProvider(content=PS_EXPECTED.strip(), relative_path=RELATIVE_PATH)
    assert result.content == expected.content
    assert result.relative_path == expected.relative_path
Ejemplo n.º 16
0
def test_candlpin_broker_no_sensitive_info():
    candlepin_broker_file = Mock()
    candlepin_broker_file.content = CANDLEPIN_BROKER_NO_SENSITIVE_INFO.splitlines()
    broker = {candlepin_broker.LocalSpecs.candlepin_broker_input: candlepin_broker_file}
    result = candlepin_broker.candlepin_broker(broker)
    assert result is not None
    assert isinstance(result, DatasourceProvider)
    expected = DatasourceProvider(content=CANDLE_BROKER_NO_SENTISVE_INFO.splitlines(), relative_path=RELATIVE_PATH)
    xml_check_removed(result.content)
    xml_compare(result.content, expected.content)
    assert result.relative_path == expected.relative_path
Ejemplo n.º 17
0
def test_lpstat_datasource():
    lpstat_data = Mock()
    lpstat_data.content = LPSTAT_V.splitlines()
    broker = {LocalSpecs.lpstat_v: lpstat_data}
    result = lpstat_protocol_printers_info(broker)
    assert result is not None
    assert isinstance(result, DatasourceProvider)
    expected = DatasourceProvider(content=LPSTAT_V_RESULT,
                                  relative_path=RELATIVE_PATH)
    assert result.content == expected.content
    assert result.relative_path == expected.relative_path
Ejemplo n.º 18
0
def _create_mock_template(mock_template_filename="", mock_template_content=""):
    """
    Returns a mock template
    :param mock_template_filename:
    :param mock_template_content:
    :return:
    """
    mock_template = Mock(spec=Template)
    mock_template.filename = mock_template_filename
    mock_template.content = mock_template_content
    mock_template.id = ObjectId()
    return mock_template
Ejemplo n.º 19
0
def _create_mock_type(filename="", content=""):
    """Returns a mock type

    Args:
        filename:
        content:

    Returns:

    """
    mock_type = Mock(spec=Type)
    mock_type.filename = filename
    mock_type.content = content
    mock_type.id = ObjectId()
    return mock_type
Ejemplo n.º 20
0
def test_cloud_cfg(ssh_deletekeys):
    cloud_cfg_string = CLOUD_CFG.format(value=ssh_deletekeys)
    cloud_cfg_dict = CLOUD_CFG_JSON.copy()
    cloud_cfg_dict["ssh_deletekeys"] = ssh_deletekeys

    cloud_init_file = Mock()
    cloud_init_file.content = cloud_cfg_string.splitlines()
    broker = {LocalSpecs.cloud_cfg_input: cloud_init_file}
    result = cloud_cfg(broker)
    assert result is not None
    assert isinstance(result, DatasourceProvider)
    expected = DatasourceProvider(content=json.dumps(cloud_cfg_dict),
                                  relative_path=RELATIVE_PATH)
    assert result.content == expected.content
    assert result.relative_path == expected.relative_path
Ejemplo n.º 21
0
def _create_mock_type(filename="", content="", is_disable=False):
    """Returns a mock type

    Args:
        filename:
        content:
        is_disable:

    Returns:

    """
    mock_type = Mock(spec=Type)
    mock_type.filename = filename
    mock_type.content = content
    mock_type.id = ObjectId()
    mock_type.is_disabled = is_disable
    return mock_type
Ejemplo n.º 22
0
def test_exception():
    ipcs_command = Mock()
    ipcs_command.content = IPCS_OUTPUT2.splitlines()
    broker = {Specs.ipcs_s: ipcs_command}
    with pytest.raises(SkipComponent):
        ipcs.semid(broker)
Ejemplo n.º 23
0
def test_ethernet_interfaces_bad():
    ip_link_command = Mock()
    ip_link_command.content = IP_LINK_BAD.splitlines()
    broker = {LocalSpecs.ip_link: ip_link_command}
    with pytest.raises(SkipComponent):
        interfaces(broker)
Ejemplo n.º 24
0
def _create_mock_xsl_transformation(name=None, filename=None, content=None):
    mock_xslt = Mock(spec=XslTransformation)
    mock_xslt.name = name
    mock_xslt.filename = filename
    mock_xslt.content = content
    return mock_xslt