Beispiel #1
0
def test_exit_ok(insights_config, insights_client):
    """
    Support collection replaces the normal client run.
    """
    with raises(SystemExit) as exc_info:
        collect_and_output()
    assert exc_info.value.code == 0
def test_exit_ok(insights_config, insights_client):
    """
    Support collection replaces the normal client run.
    """
    insights_config.return_value.load_all.return_value.compliance = False
    with raises(SystemExit) as exc_info:
        collect_and_output()
    assert exc_info.value.code == 0
Beispiel #3
0
def test_no_upload(insights_config, insights_client):
    '''
    Copy collected data to a specified file and do not upload.
    '''
    insights_config.return_value.load_all.return_value.no_upload = True
    try:
        collect_and_output()
    except SystemExit:
        pass
    insights_client.upload.assert_not_called()
Beispiel #4
0
def test_output_dir(insights_config, insights_client):
    '''
    Copy collected data to a specified directory and do not upload.
    '''
    insights_config.return_value.load_all.return_value.no_upload = True
    insights_config.return_value.load_all.return_value.output_dir = '/var/tmp/test'
    try:
        collect_and_output()
    except SystemExit:
        pass
    insights_client.return_value.copy_to_output_dir.assert_called_with(
        insights_client.return_value.collect.return_value)
Beispiel #5
0
def test_collect_and_output_payload_off(insights_config, insights_client):
    """
    Collection is done and uploaded in normal operation (no payload)
    Archive deleted after upload
    """
    insights_config.return_value.load_all.return_value.payload = False
    try:
        collect_and_output()
    except SystemExit:
        pass
    insights_client.return_value.collect.assert_called_once()
    insights_client.return_value.upload.assert_called_with(
        payload=insights_client.return_value.collect.return_value,
        content_type='application/vnd.redhat.advisor.collection+tgz')
    insights_client.return_value.delete_cached_branch_info.assert_called_once()
def test_collect_and_output_payload_on(insights_config, insights_client):
    """
    Collection is not done when a payload is uploaded
    Payload is sent to upload function
    Archive is not deleted
    """
    insights_config.return_value.load_all.return_value.payload = 'testp'
    insights_config.return_value.load_all.return_value.content_type = 'testct'
    try:
        collect_and_output()
    except SystemExit:
        pass
    insights_client.return_value.collect.assert_not_called()
    insights_client.return_value.upload.assert_called_with(payload='testp', content_type='testct')
    insights_client.return_value.delete_archive.assert_not_called()