示例#1
0
def test_device_handling():
    sub_d = Device(name='sub_device')
    main_d = Device(name='main_device')
    sub = HXDGroup(sub_d, name='sub')
    main = HXDGroup(main_d, sub, name='main')
    assert main.children == (main_d, sub)
    assert main.devices == [main_d, sub_d]
    assert main.subgroups == [sub]
    assert sub.subgroups == []
示例#2
0
def test_device_recursion():
    bot_d = Device(name='bot_device')
    low_d = Device(name='low_device')
    sub_d = Device(name='sub_device')
    main_d = Device(name='main_device')
    bot = HXDGroup(bot_d, name='bottom')
    low = HXDGroup(low_d, bot, name='low')
    sub = HXDGroup(sub_d, low, name='sub')
    main = HXDGroup(main_d, sub, name='main')
    assert bot_d in main.devices
    assert low_d in main.devices
    assert sub_d in main.devices
示例#3
0
def simul_stand(simul_device):
    #Create subdevices
    dev_1 = copy.deepcopy(simul_device)
    dev_1.name = 'Device One'
    dev_2 = copy.deepcopy(simul_device)
    dev_2.name = 'Device Two'
    dev_3 = copy.deepcopy(simul_device)
    dev_3.name = 'Device Three'
    return HXDGroup(dev_1, dev_2, dev_3, name='Stand Group')
示例#4
0
def test_stand_indicator():
    d1 = happi.Device(prefix='MMS:tst1')
    d2 = happi.Device(prefix='MMS:tst2')
    d3 = happi.Device(prefix='MMS:tst3')
    d4 = happi.Device(prefix='MMS:tst4')
    d5 = happi.Device(prefix='MMS:tst5')
    d6 = happi.Device(prefix='MMS:tst6')
    fk = happi.Device(prefix='CAM:tst6')
    sub = HXDGroup(d1, d2, d3, fk, name='sub')
    main = HXDGroup(d4, d5, d6, sub, name='main')
    button = StandIndicator(main)
    #Check button
    assert isinstance(button.widgets[0], MenuButton)
    assert str(button.widgets[0].controlPv) == str(main.pv)
    #Check columns
    assert len(button.widgets) == 8
    assert len(button.widgets[-1].widgets) == 1

    #Resize and check columns
    StandIndicator.max_col_height = 3
    button = StandIndicator(main)
    assert len(button.widgets) == 8
    assert len(button.widgets[-1].widgets) == 2
示例#5
0
def test_stand_button():
    sub = HXDGroup(name='sub')
    group = HXDGroup(sub, name='DG2')
    button = StandButton(group)
    assert button.stand_symbol.text == 'DG2'
    assert len(button.widgets) == 2
示例#6
0
def simul_device():
    test_dir = os.path.dirname(os.path.abspath(__file__))
    group = HXDGroup(
        Device(name='a',
               prefix='MMS:a',
               embedded_screen=os.path.join(test_dir, 'tiny.edl'),
               beamline='TST',
               system='vacuum'),
        Device(name='b',
               prefix='MMS:b',
               embedded_screen=os.path.join(test_dir, 'tiny.edl'),
               beamline='TST',
               system='vacuum'),
        Device(name='c',
               prefix='MMS:c',
               embedded_screen=os.path.join(test_dir, 'tiny.edl'),
               beamline='TST',
               system='vacuum'),
        Device(name='d',
               prefix='MMS:d',
               embedded_screen=os.path.join(test_dir, 'tiny.edl'),
               beamline='TST',
               system='vacuum'),
        Device(name='e',
               prefix='MMS:e',
               embedded_screen=os.path.join(test_dir, 'tiny.edl'),
               beamline='TST',
               system='vacuum'),
        Device(name='f',
               prefix='MMS:f',
               embedded_screen=os.path.join(test_dir, 'tiny.edl'),
               beamline='TST',
               system='vacuum'),
        Device(name='g',
               prefix='MMS:g',
               embedded_screen=os.path.join(test_dir, 'small.edl'),
               beamline='TST',
               system='timing'),
        Device(name='h',
               prefix='MMS:h',
               embedded_screen=os.path.join(test_dir, 'small.edl'),
               beamline='TST',
               system='timing'),
        Device(name='i',
               prefix='MMS:i',
               embedded_screen=os.path.join(test_dir, 'small.edl'),
               beamline='TST',
               system='timing'),
        Device(name='j',
               prefix='MMS:j',
               embedded_screen=os.path.join(test_dir, 'small.edl'),
               beamline='TST',
               system='timing'),
        Device(name='k',
               prefix='MMS:k',
               embedded_screen=os.path.join(test_dir, 'large.edl'),
               beamline='TST',
               system='diagnostics'),
        name='Device Group')

    return group
示例#7
0
def test_pv():
    sub_1 = HXDGroup(name='sub_1')
    sub_2 = HXDGroup(name='sub_2')
    main = HXDGroup(sub_1, sub_2, name='main')
    assert str(main.pv) == 'LOC\\\\main=e:2,sub_1,sub_2,overview'
示例#8
0
def test_alias():
    g = HXDGroup(name='DG2 TEST')
    assert g.alias == 'dg2_test'