import epics

from mgnt_auto_checkout_test import AutoCheckoutTest


class BLEMTest(AutoCheckoutTest):
    test_id = 'blem'
    description = 'BLEM'

    def __init__(self):
        super(BLEMTest, self).__init__(
            pre_checkout_routines=[]
        )

    def execute(self, magnet):
        blem_pv = magnet['device'] + ':BLEM'
        blem = epics.caget(blem_pv)
        if blem is not None:
            self.data = 'Exists'
            self.status = True
            print 'PASS'

        else:
            self.data = '{} not found'.format(blem_pv)
            self.status = False
            print 'FAIL'
