def test_canonical_path(self): locations = [ 'some/path::archive', 'file://some/path::archive', 'host:some/path::archive', 'host:~user/some/path::archive', 'ssh://host/some/path::archive', 'ssh://user@host:1234/some/path::archive' ] for location in locations: self.assert_equal( Location(location).canonical_path(), Location(Location(location).canonical_path()).canonical_path())
def test(self): self.assert_equal( repr(Location('ssh://user@host:1234/some/path::archive')), "Location(proto='ssh', user='******', host='host', port=1234, path='/some/path', archive='archive')" ) self.assert_equal( repr(Location('file:///some/path::archive')), "Location(proto='file', user=None, host=None, port=None, path='/some/path', archive='archive')" ) self.assert_equal( repr(Location('user@host:/some/path::archive')), "Location(proto='ssh', user='******', host='host', port=None, path='/some/path', archive='archive')" ) self.assert_equal( repr(Location('mybackup.attic::archive')), "Location(proto='file', user=None, host=None, port=None, path='mybackup.attic', archive='archive')" ) self.assert_equal( repr(Location('/some/absolute/path::archive')), "Location(proto='file', user=None, host=None, port=None, path='/some/absolute/path', archive='archive')" ) self.assert_equal( repr(Location('some/relative/path::archive')), "Location(proto='file', user=None, host=None, port=None, path='some/relative/path', archive='archive')" ) self.assert_raises(ValueError, lambda: Location('ssh://localhost:22/path:archive'))
def open(self, create=False): return RemoteRepository( Location('__testsuite__:' + os.path.join(self.tmppath, 'repository')), create=create)
class MockArgs(object): repository = Location(tempfile.mkstemp()[1])