def setUp(self): self.root_path = os.path.abspath(os.path.dirname(__file__) + "/../../") jsons = glob.glob(os.path.join(self.root_path, "data/*.json")) backups = glob.glob(os.path.join(self.root_path, "data/*.backup")) for file in jsons + backups: os.unlink(file) self.serials = Serials(name="serials", path=self.root_path)
class TestInterfacesClass(unittest.TestCase): def setUp(self): self.root_path = os.path.abspath(os.path.dirname(__file__) + "/../../") jsons = glob.glob(os.path.join(self.root_path, "data/*.json")) backups = glob.glob(os.path.join(self.root_path, "data/*.backup")) for file in jsons + backups: os.unlink(file) self.serials = Serials(name="serials", path=self.root_path) def tearDown(self): pass def test_get_serial(self): """Add a LogProfile, with a vaild config, \ should return LogProfile instance""" for serial in self.serials.getAll(): self.assertIn("dev", serial) self.assertIn("devDisplayName", serial) self.assertIn("mode", serial) self.assertIn("id", serial) @patch("mxserial.sh") def test_set_serial(self, sh): m = Mock() sh.setinterface = m self.serials.update(1, {"mode": "rs422/rs485-4w"}) m.assert_called_once_with("/dev/ttyM0", 2)
def init(self, *args, **kwargs): path_root = os.path.abspath(os.path.dirname(__file__)) self.serials = Serials(name="serials", path=path_root) try: self.serials.set_all() except Exception, e: _logger.error(str(e))
class Index(Sanji): def init(self, *args, **kwargs): path_root = os.path.abspath(os.path.dirname(__file__)) self.serials = Serials(name="serials", path=path_root) try: self.serials.set_all() except Exception, e: _logger.error(str(e))