def test_ref_path_symlinks_relative(fs): src = 'foo/bar/baz' dest = 'whatever/hello' fs.create_symlink('/cwd/whatever', '/cwd/foo/meh') fs.cwd = '/cwd' assert href_path(src, dest) == '../meh/hello'
def test_ref_path_same_file(): src = 'foo/bar' dest = 'foo/bar' assert href_path(src, dest) == 'bar'
def test_ref_path_absolute_to_relative(fs): src = '/somewhere/beta/file' dest = 'foo/bar' fs.cwd = '/somewhere/alpha' assert href_path(src, dest) == '../alpha/foo/bar'
def test_ref_path_symlinks(fs): src = '/foo/bar/baz' dest = '/whatever/hello' fs.create_symlink('/whatever', '/foo/meh') assert href_path(src, dest) == '../meh/hello'
def test_ref_path_child(): src = 'foo' dest = 'foo/bar' assert href_path(src, dest) == 'foo/bar'
def test_ref_path_parent(): src = 'foo/bar' dest = 'foo' assert href_path(src, dest) == '.'
def test_ref_path_root_is_only_common_ancestor_relative(fs): src = 'foo/bar' dest = 'baz/meh' fs.cwd = '/' assert href_path(src, dest) == '../baz/meh'
def test_ref_path_root_is_only_common_ancestor(): src = '/foo/bar' dest = '/baz/meh' assert href_path(src, dest) == '../baz/meh'
def test_ref_path_common_ancestor(): src = 'foo/bar/baz' dest = 'foo/meh' assert href_path(src, dest) == '../meh'
def test_ref_path_sibling_descendant(): src = 'foo/bar' dest = 'foo/baz/meh' assert href_path(src, dest) == 'baz/meh'
def test_ref_path_same_dir(): src = 'foo/bar' dest = 'foo/baz' assert href_path(src, dest) == 'baz'