def _set_auto_start(self, b): """ Getter :param b: A boolean. :type b: bool """ mb = SolBase.to_bool(b) if not SolBase.is_bool(mb): logger.error("not a boolean, class=%s", SolBase.get_classname(mb)) raise Exception("not a boolean") else: self._auto_start = mb
def _set_onstop_call_client_stopsynch(self, b): """ Getter :param b: A boolean. :type b: bool """ mb = SolBase.to_bool(b) if not SolBase.is_bool(mb): logger.error("not a boolean, class=%s", SolBase.get_classname(mb)) raise Exception("not a boolean") else: self._onstop_callclient_stopsynch = mb
def _set_ssl_enable(self, b): """ Enable or disable ssl. :param b: Boolean. :type b: bool """ is_enable = SolBase.to_bool(b) if not SolBase.is_bool(is_enable): logger.error("not a boolean, class=%s", SolBase.get_classname(is_enable)) raise Exception("not a boolean") else: self._ssl_enable = is_enable
def test_conversion(self): """ Test """ self.assertEqual(SolBase.to_int(10), 10) self.assertEqual(SolBase.to_int("10"), 10) self.assertEqual(SolBase.to_int(-10), -10) self.assertEqual(SolBase.to_int("-10"), -10) self.assertIsInstance(SolBase.to_int(10), int) self.assertRaises(Exception, SolBase.to_int, "aaa") self.assertEqual(SolBase.to_bool(True), True) self.assertEqual(SolBase.to_bool(False), False) self.assertEqual(SolBase.to_bool("1"), True) self.assertEqual(SolBase.to_bool("True"), True) self.assertEqual(SolBase.to_bool("0"), False) self.assertEqual(SolBase.to_bool("False"), False) self.assertIsInstance(SolBase.to_bool(True), bool) self.assertIsInstance(SolBase.to_bool(False), bool) self.assertRaises(Exception, SolBase.to_bool, "dummy")