Ejemplo n.º 1
0
 def test2_0_save_cfg(self):
     """
     Pin >2_0> Write empty pin0
     """
     cfg_file = '%s/misc/tmp_test.cfg' % PREFIX
     if os.path.exists(cfg_file):
         os.remove(cfg_file)
     pin = SlavePin(self.opt)
     pin.write_cfg(cfg_file)
     self.assertTrue(pin.crypt == '9ec78ec1ae354d5cd568a90ab2f1493a',
                     "CRYPT: %s" % pin.crypt)
     os.remove(cfg_file)
Ejemplo n.º 2
0
 def test2_1_save_cfg(self):
     """
     Pin >2_1> Write real pin1 cfg
     """
     test1_cfg = "%s/packaged/etc/raspigpioctrl/pin1.cfg" % PREFIX
     pin = SlavePin(self.opt, test1_cfg)
     pin.start = "10:00"
     pin.duration = "30"
     pin.dow = "Fri,Sat,Sun"
     cfg_file = '%s/misc/tmp_test.cfg' % PREFIX
     if os.path.exists(cfg_file):
         os.remove(cfg_file)
     pin.write_cfg(cfg_file)
     self.assertTrue(pin.crypt == '80a913b6297d386cd72b9f9fd9172c34',
                     "CRYPT: %s" % pin.crypt)
     os.remove(cfg_file)
Ejemplo n.º 3
0
 def test2_2_failed_save_cfg(self):
     """
     Pin >2_2> Write cfg with changed cfg-file in background (IOError)
     """
     test1_cfg = "%s/packaged/etc/raspigpioctrl/pin1.cfg" % PREFIX
     pin = SlavePin(self.opt, test1_cfg)
     cfg = {
         'start': "10:00",
         'duration': "30",
         'dow': "Fri,Sat,Sun"
     }
     pin.set_cfg(cfg)
     cfg_file = '%s/misc/tmp_test.cfg' % PREFIX
     if os.path.exists(cfg_file):
         os.remove(cfg_file)
     pin.write_cfg(cfg_file)
     self.assertTrue(pin.crypt == '80a913b6297d386cd72b9f9fd9172c34',
                     "CRYPT: %s" % pin.crypt)
     
     cfg = {'start': "10:30"}
     pin.set_cfg(cfg)
     os.system("echo FooBar >> %s" % cfg_file)
     self.assertRaises(IOError, pin.write_cfg, (cfg_file))
     os.remove(cfg_file)