def test_is_tldname(self): valid_tldnames = ["com", "net", "org", "co.uk"] invalid_tldnames = [ # Invalid Formats "com.", ".com", # Trailing newline - Bug 1471158 "com\n", ] for tldname in valid_tldnames: self.assertTrue(format.is_tldname(tldname), "Expected Valid: %s" % tldname) for tldname in invalid_tldnames: self.assertFalse(format.is_tldname(tldname), "Expected Invalid: %s" % tldname)
def test_is_tldname(self): valid_tldnames = [ 'com', 'net', 'org', 'co.uk', ] invalid_tldnames = [ # Invalid Formats 'com.', '.com', # Trailing newline - Bug 1471158 "com\n", ] for tldname in valid_tldnames: self.assertTrue(format.is_tldname(tldname), 'Expected Valid: %s' % tldname) for tldname in invalid_tldnames: self.assertFalse(format.is_tldname(tldname), 'Expected Invalid: %s' % tldname)
def validate_and_create_tld(self, line, error_lines): # validate the tld name if not format.is_tldname(line['name']): error_lines.append("InvalidTLD --> " + self.convert_tld_dict_to_str(line)) return 0 # validate the description if there is one elif (line['description']) and (len(line['description']) > 160): error_lines.append("InvalidDescription --> " + self.convert_tld_dict_to_str(line)) return 0 else: try: self.central_api.create_tld(self.context, values=line) return 1 except exceptions.DuplicateTLD: error_lines.append("DuplicateTLD --> " + self.convert_tld_dict_to_str(line)) return 0
def _validate_and_create_tld(self, line, error_lines): # validate the tld name if not format.is_tldname(line['name']): error_lines.append("InvalidTld --> " + self._convert_tld_dict_to_str(line)) return 0 # validate the description if there is one elif (line['description']) and (len(line['description']) > 160): error_lines.append("InvalidDescription --> " + self._convert_tld_dict_to_str(line)) return 0 else: try: self.central_api.create_tld(self.context, values=line) return 1 except exceptions.DuplicateTld: error_lines.append("DuplicateTld --> " + self._convert_tld_dict_to_str(line)) return 0