Beispiel #1
0
def test_drpsys_2_instruments(drpmocker):
    """Test that two DRPs are returned"""

    drpdata1 = pkgutil.get_data('numina.drps.tests', 'drptest1.yaml')
    drpdata2 = pkgutil.get_data('numina.drps.tests', 'drptest2.yaml')
    drpmocker.add_drp('TEST1', drpdata1)
    drpmocker.add_drp('TEST2', drpdata2)

    drpsys = DrpSystem()
    drpsys.load()

    ldrp1 = drpsys.query_by_name('TEST1')

    assert ldrp1 is not None
    assert ldrp1.name == 'TEST1'

    ldrp2 = drpsys.query_by_name('TEST2')

    assert ldrp2 is not None
    assert ldrp2.name == 'TEST2'

    res = drpsys.query_by_name('OTHER')
    assert res is None

    alldrps = drpsys.query_all()
    assert len(alldrps) == 2
    assert 'TEST1' in alldrps
    # FIXME: We should check that both are equal, not just the name
    assert alldrps['TEST1'].name == ldrp1.name

    assert 'TEST2' in alldrps
    # FIXME: We should check that both are equal, not just the name
    assert alldrps['TEST2'].name == ldrp2.name
Beispiel #2
0
def test_drpsys_bad_file(capsys, drpmocker):
    """Test that a bad file doesn't break the load"""

    drpdata3 = pkgutil.get_data('numina.drps.tests', 'drptest3.yaml')

    drpmocker.add_drp('TEST3', drpdata3)
    drpsys = DrpSystem()
    drpsys.load()
    expected_msg = [
        '',
        "Error is:  Missing key 'modes' inside 'root' node",
        'Problem loading TEST3 = TEST3.loader'
    ]

    out, err = capsys.readouterr()
    err = err.split("\n")
    err.sort()

    assert err == expected_msg
Beispiel #3
0
def test_fake_pipeline(monkeypatch):

    def mockreturn(group=None):

        def fake_loader():
            confs = None
            modes = None
            pipelines = {'default': Pipeline('default', {}, 1)}
            fake = InstrumentDRP('FAKE', confs, modes, pipelines)
            return fake

        ep = pkg_resources.EntryPoint('fake', 'fake.loader')
        monkeypatch.setattr(ep, 'load', lambda: fake_loader)
        return [ep]

    monkeypatch.setattr(pkg_resources, 'iter_entry_points', mockreturn)

    alldrps = DrpSystem().load().query_all()
    for k, v in alldrps.items():
        assert_valid_instrument(v)
Beispiel #4
0
def test_drpsys_no_instrument():

    drpsys = DrpSystem()
    drpsys.load()

    res = drpsys.query_by_name('TEST1')
    assert res is None

    res = drpsys.query_by_name('TEST2')
    assert res is None

    res = drpsys.query_by_name('OTHER')
    assert res is None

    alldrps = drpsys.query_all()
    assert len(alldrps) == 0
Beispiel #5
0
def test_drpsys_one_instrument(drpmocker):
    """Test that only one DRP is returned."""

    drpdata1 = pkgutil.get_data('numina.drps.tests', 'drptest1.yaml')

    drpmocker.add_drp('TEST1', drpdata1)

    drpsys = DrpSystem()
    drpsys.load()

    ldrp = drpsys.query_by_name('TEST1')

    assert ldrp is not None
    assert ldrp.name == 'TEST1'

    res = drpsys.query_by_name('OTHER')
    assert res is None

    alldrps = drpsys.query_all()
    assert len(alldrps) == 1
    assert 'TEST1' in alldrps
    # FIXME: We should check that both are equal, not just the name
    assert alldrps['TEST1'].name == ldrp.name