def test_invalid_IPv6_address(self): # The server will error out with this so we treat it as invalid. option = config_options.IpAddress() self.assertRaises( config_options.ValidationError, option.validate, '[::1]:8000' )
def test_IP_normalization(self): addr = '127.000.000.001:8000' option = config_options.IpAddress(default=addr) value = option.validate(None) self.assertEqual(str(value), '127.0.0.1:8000') self.assertEqual(value.host, '127.0.0.1') self.assertEqual(value.port, 8000)
def test_valid_address(self): addr = '127.0.0.1:8000' option = config_options.IpAddress() value = option.validate(addr) self.assertEqual(str(value), addr) self.assertEqual(value.host, '127.0.0.1') self.assertEqual(value.port, 8000)
def test_named_address(self): addr = 'localhost:8000' option = config_options.IpAddress() value = option.validate(addr) self.assertEqual(str(value), addr) self.assertEqual(value.host, 'localhost') self.assertEqual(value.port, 8000)
# The directory containing the documentation markdown. ('docs_dir', config_options.Dir(default='docs', exists=True)), # The directory where the site will be built to ('site_dir', config_options.SiteDir(default='site')), # A copyright notice to add to the footer of documentation. ('copyright', config_options.Type(str)), # set of values for Google analytics containing the account IO and domain, # this should look like, ['UA-27795084-5', 'mkdocs.org'] ('google_analytics', config_options.Type(list, length=2)), # The address on which to serve the live reloading docs server. ('dev_addr', config_options.IpAddress(default='127.0.0.1:8000')), # If `True`, use `<page_name>/index.hmtl` style files with hyperlinks to # the directory.If `False`, use `<page_name>.html style file with # hyperlinks to the file. # True generates nicer URLs, but False is useful if browsing the output on # a filesystem. ('use_directory_urls', config_options.Type(bool, default=True)), # Specify a link to the project source repo to be included # in the documentation pages. ('repo_url', config_options.RepoURL()), # A name to use for the link to the project source repo. # Default, If repo_url is unset then None, otherwise # "GitHub", "Bitbucket" or "GitLab" for known url or Hostname
def test_unsupported_IPv6_address(self): option = config_options.IpAddress() value = option.validate(':::8000') option.post_validation({'dev_addr': value}, 'dev_addr') self.assertEqual(len(option.warnings), 1)
def test_invalid_address_missing_port(self): option = config_options.IpAddress() self.assertRaises( config_options.ValidationError, option.validate, '127.0.0.1' )
def test_invalid_address_type(self): option = config_options.IpAddress() self.assertRaises( config_options.ValidationError, option.validate, 123 )
def test_invalid_address_format(self): option = config_options.IpAddress() self.assertRaises( config_options.ValidationError, option.validate, '127.0.0.18000' )
def test_invalid_address_range(self): option = config_options.IpAddress() self.assertRaises( config_options.ValidationError, option.validate, '277.0.0.1:8000' )