fault.defects

module
import

cmbx
function

cmbx(t)

Yield a list of combinations using a mask

expectation_samples
data

expectation_samples = (
	(
		'',
		('none', None, None, None, None, None),
		{
			'type': 'none',
			'scheme': None,
		}
	),

	# cover the amorphous type.
	# indicates a 'none' scheme, but where the remaining
	(
		'x@fault.io:80',
		('amorphous', None, 'x@fault.io:80', None, None, None),
		{
			'type': 'amorphous',
			'scheme' : None,
			'host': 'fault.io',
			'port': '80',
			'user': 'x',
		}
	),

	(
		'fault.io:80',
		('amorphous', None, 'fault.io:80', None, None, None),
		{
			'type': 'amorphous',
			'scheme' : None,
			'host': 'fault.io',
			'port': '80',
		}
	),

	(
		'/path1/',
		('none', None, None, 'path1/', None, None),
		{
			'type': 'none',
			'scheme' : None,
			'path' : ['path1',''],
		}
	),

	(
		'host',
		('none', None, 'host', None, None, None),
		{
			'type' : 'none',
			'scheme': None,
			'host' : 'host',
		}
	),

	(
		'http://host',
		('authority', 'http', 'host', None, None, None),
		{
			'type': 'authority',
			'scheme' : 'http',
			'host' : 'host',
		}
	),

	# arbitrary scheme support
	(
		'x-un+known://host',
		('authority', 'x-un+known', 'host', None, None, None),
		{
			'type': 'authority',
			'scheme' : 'x-un+known',
			'host' : 'host',
		}
	),

	(
		'http://host/',
		('authority', 'http', 'host', '', None, None),
		{
			'type': 'authority',
			'scheme' : 'http',
			'host' : 'host',
			'path' : [],
		}
	),

	(
		'http://host/path1',
		('authority', 'http', 'host', 'path1', None, None),
		{
			'type' : 'authority',
			'scheme' : 'http',
			'host' : 'host',
			'path' : ['path1'],
		}
	),

	(
		'mailto:',
		('absolute', 'mailto', None, None, None, None),
		{
			'type': 'absolute',
			'scheme' : 'mailto',
		}
	),

	(
		'mailto:x@fault.io',
		('absolute', 'mailto', 'x@fault.io', None, None, None),
		{
			'type': 'absolute',
			'scheme' : 'mailto',
			'user': 'x',
			'host': 'fault.io',
		}
	),

	(
		'mailto:x@fault.io?foo=bar',
		('absolute', 'mailto', 'x@fault.io', None, 'foo=bar', None),
		{
			'type': 'absolute',
			'scheme' : 'mailto',
			'user': 'x',
			'host': 'fault.io',
			'query': [
				('foo', 'bar')
			]
		}
	),

	(
		'//host:/path1/',
		('relative', None, 'host:', 'path1/', None, None),
		{
			'type': 'relative',
			'scheme' : None,
			'host' : 'host',
			'port' : '',
			'path' : ['path1',''],
		}
	),

	(
		'//host/path1/',
		('relative', None, 'host', 'path1/', None, None),
		{
			'type': 'relative',
			'scheme' : None,
			'host' : 'host',
			'path' : ['path1',''],
		}
	),

	(
		'http://host/path1/',
		('authority', 'http', 'host', 'path1/', None, None),
		{
			'type': 'authority',
			'scheme' : 'http',
			'host' : 'host',
			'path' : ['path1',''],
		}
	),
	(
		'http://host/path1/path2',
		('authority', 'http', 'host', 'path1/path2', None, None),
		{
			'type': 'authority',
			'scheme' : 'http',
			'host' : 'host',
			'path' : ['path1','path2'],
		}
	),
	(
		'http://host/path1/path2?k=v&k2=v2',
		('authority', 'http', 'host', 'path1/path2', 'k=v&k2=v2', None),
		{
			'type': 'authority',
			'scheme' : 'http',
			'host' : 'host',
			'path' : ['path1','path2'],
			'query' : [('k', 'v'), ('k2', 'v2')],
		}
	),
	(
		'http://host/path1/path2?k=v',
		('authority', 'http', 'host', 'path1/path2', 'k=v', None),
		{
			'type': 'authority',
			'scheme' : 'http',
			'host' : 'host',
			'path' : ['path1','path2'],
			'query' : [('k', 'v')],
		}
	),
	(
		'http://host/path1/path2?k=v#',
		('authority', 'http', 'host', 'path1/path2', 'k=v', ''),
		{
			'type': 'authority',
			'scheme' : 'http',
			'host' : 'host',
			'path' : ['path1','path2'],
			'query' : [('k', 'v')],
			'fragment' : '',
		}
	),
	(
		'http://host/path1/path2?k=v#fragment',
		('authority', 'http', 'host', 'path1/path2', 'k=v', 'fragment'),
		{
			'type': 'authority',
			'scheme' : 'http',
			'host' : 'host',
			'path' : ['path1','path2'],
			'query' : [('k', 'v')],
			'fragment' : 'fragment',
		}
	),
	(
		'http://host:port/path1/path2?k=v#fragment',
		('authority', 'http', 'host:port', 'path1/path2', 'k=v', 'fragment'),
		{
			'type': 'authority',
			'scheme' : 'http',
			'host' : 'host',
			'port' : 'port',
			'path' : ['path1','path2'],
			'query' : [('k', 'v')],
			'fragment' : 'fragment',
		}
	),
	(
		'http://user@host:port/path1/path2?k=v#fragment',
		('authority', 'http', 'user@host:port', 'path1/path2', 'k=v', 'fragment'),
		{
			'type': 'authority',
			'scheme' : 'http',
			'user' : 'user',
			'host' : 'host',
			'port' : 'port',
			'path' : ['path1','path2'],
			'query' : [('k', 'v')],
			'fragment' : 'fragment',
		}
	),
	(
		'http://user:pass@host:port/path1/path2?k=v#fragment',
		('authority', 'http', 'user:pass@host:port', 'path1/path2', 'k=v', 'fragment'),
		{
			'type': 'authority',
			'scheme' : 'http',
			'user' : 'user',
			'password' : 'pass',
			'host' : 'host',
			'port' : 'port',
			'path' : ['path1','path2'],
			'query' : [('k', 'v')],
			'fragment' : 'fragment',
		}
	),
	(
		'ftp://user:pass@host:port/pa%2Fth1/path2?#',
		('authority', 'ftp', 'user:pass@host:port', 'pa%2Fth1/path2', '', ''),
		{
			'type': 'authority',
			'scheme' : 'ftp',
			'user' : 'user',
			'password' : 'pass',
			'host' : 'host',
			'port' : 'port',
			'path' : ['pa/th1','path2'],
			'query' : [],
			'fragment' : '',
		}
	),
	(
		'ftp://us%40er:pa:ss@host:port/pa%2Fth1/path2?#',
		('authority', 'ftp', 'us%40er:pa:ss@host:port', 'pa%2Fth1/path2', '', ''),
		{
			'type': 'authority',
			'scheme' : 'ftp',
			'user' : 'us@er',
			'password' : 'pa:ss',
			'host' : 'host',
			'port' : 'port',
			'path' : ['pa/th1','path2'],
			'query' : [],
			'fragment' : '',
		}
	),
	(
		'ftp://us%40er:pa:ss@host:port/pa%2Fth1/path2?%23=%23#',
		('authority', 'ftp', 'us%40er:pa:ss@host:port', 'pa%2Fth1/path2', '%23=%23', ''),
		{
			'type': 'authority',
			'scheme' : 'ftp',
			'user' : 'us@er',
			'password' : 'pa:ss',
			'host' : 'host',
			'port' : 'port',
			'path' : ['pa/th1','path2'],
			'query' : [('#', '#')],
			'fragment' : '',
		}
	),
	(
		'http://us%40er:pa:ss@host[address]:port/pa%2Fth1/path2?%23=%23#',
		('authority', 'http', 'us%40er:pa:ss@host[address]:port', 'pa%2Fth1/path2', '%23=%23', ''),
		{
			'type': 'authority',
			'scheme': 'http',
			'user': 'us@er',
			'password': 'pa:ss',
			'host': 'host',
			'address': 'address',
			'port': 'port',
			'path': ['pa/th1','path2'],
			'query': [('#', '#')],
			'fragment': '',
		}
	),
)

sample_join_netlocs
data

sample_join_netlocs = (
	'sample.com',
	'host',
	'host:port',
	'host:8080',
	'@host',
	'%40@',
	'%40:@host',
	'user@',
	'user:@',
	'user:pass@',
	':@host',
	':@host:8080',
	'user:@host:8080',
	'user:@host[addr]:8080',
	'user:@host[127.1]:8080',
	'user:@[]:8080',
	'user:@[::1]:8080',
	'user:@[text]:8080',
	'user:@[:8080',
	'user:@[fe80::1]:8080',
	'user:pass@host:8080',
	'user:pass@host',
)

sample_split_netlocs
data

sample_split_netlocs = (
	('user', 'pass', 'host', None, 'port'),
	('@', ':', 'host', None, 'port'),
	('@user', 'pass:', 'host', None, 'port'),
	('@user', 'pass:', 'host', None, ''),
	('@user', 'pass:', '', None, ''),
	('user', '@', 'host.com', None, ''),
	('user', '@', 'å.com', None, '8080'),
	('user', '', 'x--na.com', None, '8080'),
	('', '', 'x--na.com', None, '8080'),
	('', '', '', None, '8080'),
	('', '', '', None, ''),
)

sample_join_paths
data

sample_join_paths = (
	None,
	'',
	'/',
	'///',
	'/path',
	'/path/path2',
	'/path/path2/',
	'/path2',
	'/åß∂',
	'/åß∂/',
	'/åß∂//',
	'/element1/element2/element3',
)

sample_schemes
data

sample_schemes = (
	('authority', 'http'),
	('relative', None),
	('absolute', 'https'),
)

sample_users
data

sample_users = (
	'',
	':',
	'@',
	'user@',
	'user',
	'jæms',
)

sample_passwords
data

sample_passwords = [
	'',
	':',
	'@',
	'æçèêí',
]

sample_hosts
data

sample_hosts = [
	'',
	'host',
	#'[::1', Fail case. Can't use this host and correctly identify the port.
	#'::1]', Fail case. Can't use this host and correctly identify the port.
	'remotehost.tld',
]

sample_addresses
data

sample_addresses = [
	None,
	'',
	'::1',
]

sample_ports
data

sample_ports = [
	'',
	'80',
	'foo',
	':',
]

sample_paths
data

sample_paths = (
	[],
	# [''], Fail case. Can't represent this structure consistently.
	['', ''],
	['/',],
	['path/'],
	['path','/path2'],
)

sample_queries
data

sample_queries = (
	[],
	# [('', None)], Fail case. Can't represent this structure consistently.
	[('key', None)],
	[('key', 'val'), ('key', None), ('?', '=')],
	[('=', '=')],
)

sample_fragments
data

sample_fragments = (
	'',
	'#',
	'\x05',
	'%05',
)

samples
function

samples()

test_expectations
function

test_expectations(test)

test_split_join_netloc
function

test_split_join_netloc(test)

test_join_split_netloc
function

test_join_split_netloc(test)

test_split_join_path
function

test_split_join_path(test)

test_join_split_path
function

test_join_split_path(test)

test_combinations
function

test_combinations(test)

test_strict
function

test_strict(test)

test_address_extension
function

test_address_extension(test)

Validate the address extension.