def __validate_input(self) -> bool: if not utilities.valid_ip_address(self._leIpAddr.text()): utilities.show_error_message_box(self, self.__ERR_MSG_INVALID_IP + self._leIpAddr.text()) return False if not utilities.valid_port(self._lePort.text()): utilities.show_error_message_box(self, self.__ERR_MSG_INVALID_PORT + self._lePort.text()) return False if len(self._leUserName.text()) == 0: utilities.show_error_message_box(self, self.__ERR_MSG_INVALID_USER) return False if len(self._lePasswd.text()) == 0: utilities.show_error_message_box(self, self.__ERR_MSG_INVALID_PASSWD) return False return True
def test_validIpAddress_returnTrue_whenIpAddressIsInValid(self): self.assertFalse(utilities.valid_ip_address('192.168.0.'))
def test_validIpAddress_returnFalse_whenIpAddressOutOfRange(self): self.assertFalse(utilities.valid_ip_address('255.256.345.0'))
def test_validIpAddress_returnTrue_whenIpAddressIsLocalHost(self): self.assertTrue(utilities.valid_ip_address('localhost'))
def test_validIpAddress_returnFalse_whenStringContainsIllegalChar(self): self.assertFalse(utilities.valid_ip_address('password'))