Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
 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))
Exemplo n.º 5
0
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))
Exemplo n.º 6
0
 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)