Example #1
0
def test_payload_upload(op, post, c, _legacy_upload_archive):
    '''
    Ensure a payload upload occurs with the right URL and params
    '''
    conf = InsightsConfig(legacy_upload=False)
    c = InsightsConnection(conf)
    c.upload_archive('testp', 'testct', None)
    post.assert_called_with(
        c.base_url + '/ingress/v1/upload',
        files={
            'file': (
                'testp', ANY, 'testct'
            ),  # ANY = return call from mocked open(), acts as filepointer here
            'metadata':
            json.dumps({
                'test': 'facts',
                'branch_info': {
                    'remote_branch': -1,
                    'remote_leaf': -1
                },
                'satellite_id': -1,
            })
        },
        headers={})
    _legacy_upload_archive.assert_not_called()
Example #2
0
def test_legacy_upload_func(_legacy_upload_archive):
    '''
    Ensure the _legacy_upload_archive path is used
    '''
    conf = InsightsConfig()
    c = InsightsConnection(conf)
    c.upload_archive('testp', 'testct', None)
    _legacy_upload_archive.assert_called_with('testp', None)
Example #3
0
def test_payload_upload(op, session):
    '''
    Ensure a payload upload occurs with the right URL and params
    '''
    conf = InsightsConfig(legacy_upload=False)
    c = InsightsConnection(conf)
    c.upload_archive('testp', 'testct', None)
    c.session.post.assert_called_with(
        'https://' + c.config.base_url + '/platform/upload/api/v1/upload',
        files={'upload': ('testp', ANY, 'testct')},  # ANY = return call from mocked open(), acts as filepointer here
        headers={})
Example #4
0
def test_legacy_upload(op, session):
    '''
    Ensure an Insights collected tar upload to legacy occurs with the right URL and params
    '''
    conf = InsightsConfig()
    c = InsightsConnection(conf)
    c.upload_archive('testp', 'testct', None)
    c.session.post.assert_called_with(
        'https://' + c.config.base_url + '/uploads/XXXXXXXX',
        files={'file': ('testp', ANY, 'application/gzip')},  # ANY = return call from mocked open(), acts as filepointer here
        headers={'x-rh-collection-time': 'None'})