Ejemplo n.º 1
0
 def test0_3_init(self):
     """
     Pin >0_3> change cfg of init_pin
     """
     pin = SlavePin(self.opt)
     exp_items = {
         'crypt': None,
         'pin_nr': '0',
         'cfg_file': None,
         'name': 'None',
         'prio': '0',
         'mode': 'off',
         'groups': '',
         'start': '00:00',
         'duration': '0',
         'sun_delay': '0',
         'state': '0',
         'dow': 'Mon,Tue,Wed,Thu,Fr,Sat,Sun',
         'gpio_base': "%spackaged/sys/class/gpio" % PREFIX,
         'pin_base': "%spackaged/sys/class/gpio/gpio0" % PREFIX,
     }
     exp1 = exp_items.copy()
     self.check_dict(pin, exp1)
     cfg = {
         'pin_nr': '1',
         'name': 'Front',
     }
     pin.set_cfg(cfg)
     pin.change_mode('time')
     exp_items['name'] = 'Front'
     exp_items['mode'] = 'time'
     pin_base = "%spackaged/sys/class/gpio/gpio1" % PREFIX
     exp_items['pin_base'] = pin_base
     exp_items['pin_nr'] = '1'
     self.check_dict(pin, exp_items)
Ejemplo n.º 2
0
 def test8_0_trigger(self):
     """
     Pin >8_0> trigger off
     """
     pin = SlavePin(self.opt)
     now = datetime.datetime.now()
     delay = datetime.timedelta(seconds=600)
     temp_on = now - delay
     cfg = {
         'start': temp_on.strftime("%H:%M"),
         'duration': '5',
         'pin_nr': '1',
     }
     pin.set_cfg(cfg)
     pin.change_mode('time')
     pin.init_pin()
     pin.set_pin(1)
     self.assertTrue("1" == pin.read_real_life())
     pin.trigger_off()
     self.assertTrue("0" == pin.read_real_life())
     pin.trigger_off()
     self.assertTrue("0" == pin.read_real_life())
     pin.set_pin(1)
     self.assertTrue("1" == pin.read_real_life())
     pin.trigger_off()
     self.assertTrue("0" == pin.read_real_life())
Ejemplo n.º 3
0
 def run_scenario(self):
     """
     run scenario w/o config files
     """
     if self.opt['--test'] == 'test1':
         pin1 = SlavePin(self.opt)
         cfg = {
             'dow': 'Mon,Tue,Wed,Thu,Fri,Sat,Sun',
             'duration': '60',
             'groups': 'grpA',
             'name': 'TestPin1',
             'pin_nr': '1',
             'start': '01:00',
         }
         pin1.set_cfg(cfg)
         pin1.set_pin(0)
         pin1.change_mode('time')
         pin1.val_path = "%s/gpio%s/value" % (pin1.gpio_base, 1)
         self.add_pin(pin1)
         pin5 = MainPin(self.opt)
         cfg = {
             'groups': 'grpA',
             'name': 'MainPin5',
             'pin_nr': '5',
             'crypt': 'eaa491247883b9b1cd0760bae439a253'
             }
         pin5.set_cfg(cfg, True)
         pin5.val_path = "%s/gpio%s/value" % (pin1.gpio_base, 5)
         pin5.cfg_file = "%s/packaged/etc/raspigpioctrl/main5.cfg" % (os.environ["WORKSPACE"])
         pin5.change_mode('off')
         pin5.set_pin(0)
         self.add_pin(pin5)
Ejemplo n.º 4
0
 def test5_0_change_mode(self):
     """
     Pin >5_0> Change mode to time, manual, sun
     """
     pin = SlavePin(self.opt)
     pin.change_mode("time")
     self.assertTrue(pin.mode == "time")
     pin.change_mode("man")
     self.assertTrue(pin.mode == "man")
     pin.change_mode("sun")
     with self.assertRaises(ValueError):
         pin.change_mode("buh")
     self.assertTrue(pin.mode == "sun")
     self.assertTrue(get_mode_id("buh") is None)