def test_export_rest(self):
        """ EXPORT (REST): Test the export of data."""
        mw = []
        headers1 = {
            'X-Rucio-Account': 'root',
            'X-Rucio-Username': '******',
            'X-Rucio-Password': '******'
        }
        r1 = TestApp(auth_app.wsgifunc(*mw)).get('/userpass',
                                                 headers=headers1,
                                                 expect_errors=True)
        token = str(r1.header('X-Rucio-Auth-Token'))
        headers2 = {
            'X-Rucio-Type': 'user',
            'X-Rucio-Account': 'root',
            'X-Rucio-Auth-Token': str(token)
        }

        r2 = TestApp(export_app.wsgifunc(*mw)).get('/',
                                                   headers=headers2,
                                                   expect_errors=True)
        rses = [export_rse(rse['rse']) for rse in list_rses()]
        assert_equal(r2.status, 200)
        assert_equal(
            r2.body,
            render_json(**{
                'rses': rses,
                'distances': export_distances()
            }))
Beispiel #2
0
 def test_export_client(self):
     """ EXPORT (CLIENT): Test the export of data."""
     export_client = ExportClient()
     data = export_client.export_data()
     rses = {}
     for rse in list_rses():
         rse_name = rse['rse']
         rses[rse_name] = export_rse(rse_name)
     assert_equal(data['rses'], parse_response(render_json(**rses)))
     assert_equal(data['distances'], parse_response(render_json(**export_distances())))
Beispiel #3
0
def export_data(session=None):
    """
    Export data.

    :param session: database session in use.
    """
    data = {
        'rses': export_rses(session=session),
        'distances': distance_module.export_distances(session=session)
    }
    return data
Beispiel #4
0
def export_data(vo='def', session=None):
    """
    Export data.

    :param vo: The VO to export.
    :param session: database session in use.
    """
    data = {
        'rses': export_rses(vo=vo, session=session),
        'distances': distance_module.export_distances(vo, session=session)
    }
    return data
Beispiel #5
0
def export_data(session=None):
    """
    Export data.

    :param session: database session in use.
    """
    data = {
        'rses': [
            rse_module.export_rse(rse['rse'], session=session)
            for rse in rse_module.list_rses(session=session)
        ],
        'distances':
        distance_module.export_distances(session=session)
    }
    return data
Beispiel #6
0
def export_data(vo='def', distance=True, session=None):
    """
    Export data.

    :param vo: The VO to export.
    :param distance: To enable the reporting of distance.
    :param session: database session in use.
    """
    if distance:
        data = {
            'rses': export_rses(vo=vo, session=session),
            'distances': distance_module.export_distances(vo, session=session)
        }
    else:
        data = {'rses': export_rses(vo=vo, session=session)}
    return data
Beispiel #7
0
    def test_export_rest(self):
        """ EXPORT (REST): Test the export of data."""
        mw = []
        headers1 = {
            'X-Rucio-Account': 'root',
            'X-Rucio-Username': '******',
            'X-Rucio-Password': '******'
        }
        headers1.update(self.vo_header)
        r1 = TestApp(auth_app.wsgifunc(*mw)).get('/userpass',
                                                 headers=headers1,
                                                 expect_errors=True)
        token = str(r1.header('X-Rucio-Auth-Token'))
        headers2 = {
            'X-Rucio-Type': 'user',
            'X-Rucio-Account': 'root',
            'X-Rucio-Auth-Token': str(token)
        }

        r2 = TestApp(export_app.wsgifunc(*mw)).get('/',
                                                   headers=headers2,
                                                   expect_errors=True)
        rses = export_rses()
        sanitised = {}
        for rse_id in rses:
            sanitised[get_rse_name(rse_id=rse_id)] = rses[rse_id]
        rses = sanitised

        assert_equal(r2.status, 200)
        assert_equal(
            json.loads(r2.body),
            json.loads(
                render_json(**{
                    'rses': rses,
                    'distances': export_distances()
                })))
Beispiel #8
0
 def test_export_core(self):
     """ EXPORT (CORE): Test the export of data."""
     data = export_data()
     assert_equal(data['rses'], export_rses())
     assert_equal(data['distances'], export_distances())