Exemplo n.º 1
0
def test_bad_file(docker_mock):
    '''Test a simple run using docker mock'''
    from func_adl_xAOD.atlas.xaod import xAODDataset
    with pytest.raises(FileNotFoundError):
        (xAODDataset(Path('/bad/path')).Select(
            lambda e: e.EventInfo("EventInfo").runNumber()).AsROOTTTree(
                'junk.root', 'my_tree', ['eventNumber']).value())
Exemplo n.º 2
0
def test_string_file(docker_mock):
    '''Test a simple run using docker mock'''
    from func_adl_xAOD.atlas.xaod import xAODDataset
    r = (xAODDataset(str(f_location)).Select(
        lambda e: e.EventInfo("EventInfo").runNumber()).AsROOTTTree(
            'junk.root', 'my_tree', ['eventNumber']).value())

    assert len(r) == 1
Exemplo n.º 3
0
def test_run(docker_mock):
    '''Test a simple run using docker mock'''
    # TODO: Using the type stuff, make sure replacing Select below with SelectMany makes a good error message
    from func_adl_xAOD.atlas.xaod import xAODDataset
    r = (xAODDataset(f_location).Select(
        lambda e: e.EventInfo("EventInfo").runNumber()).AsROOTTTree(
            'junk.root', 'my_tree', ['eventNumber']).value())

    assert len(r) == 1
Exemplo n.º 4
0
def test_alternate_dir(docker_mock):
    'Make sure we can send the file to our own directory'
    with tempfile.TemporaryDirectory() as tmpdir:
        from func_adl_xAOD.atlas.xaod import xAODDataset
        r = (xAODDataset(f_location, output_directory=Path(tmpdir)).Select(
            lambda e: e.EventInfo("EventInfo").runNumber()).AsROOTTTree(
                'junk.root', 'my_tree', ['eventNumber']).value())

        assert str(r[0]).startswith(str(tmpdir))
Exemplo n.º 5
0
def test_docker_error(docker_mock_fail):
    '''Test a simple run using docker mock'''
    from func_adl_xAOD.atlas.xaod import xAODDataset
    from python_on_whales.exceptions import DockerException
    with pytest.raises(DockerException):
        (xAODDataset([
            f_location
        ]).Select(lambda e: e.EventInfo("EventInfo").runNumber()).AsROOTTTree(
            'junk.root', 'my_tree', ['eventNumber']).value())
Exemplo n.º 6
0
def test_no_file(docker_mock):
    '''Test a simple run using docker mock'''
    from func_adl_xAOD.atlas.xaod import xAODDataset
    with pytest.raises(RuntimeError) as e:
        (xAODDataset([]).Select(
            lambda e: e.EventInfo("EventInfo").runNumber()).AsROOTTTree(
                'junk.root', 'my_tree', ['eventNumber']).value())

    assert 'No files' in str(e)
Exemplo n.º 7
0
def test_different_directories(docker_mock):
    '''Test a simple run using docker mock'''
    from func_adl_xAOD.atlas.xaod import xAODDataset
    with tempfile.TemporaryDirectory() as d:
        import shutil
        shutil.copy(f_location, d)
        file_two = Path(d) / f_location.name

        with pytest.raises(RuntimeError) as e:
            (xAODDataset([f_location, file_two]).Select(
                lambda e: e.EventInfo("EventInfo").runNumber()).AsROOTTTree(
                    'junk.root', 'my_tree', ['eventNumber']).value())

        assert 'same directory' in str(e)