コード例 #1
0
    def test_sftp(self):
        SftpPath._check_dependencies = self.mocked_dependencies
        sftp_mock = MagicMock()
        sftp_mock.hostkeys.HostKeys().items.return_value = {'key': 'value'}

        self.deps.append(sftp_mock)

        with AnyPath('ssh://user@host:example') as path:
            self.assertTrue(path.parent.exists(), 'Path was not created')
コード例 #2
0
    def test_http(self):
        HttpPath._check_dependencies = self.mocked_dependencies
        req_mock = MagicMock()
        res_mock = MagicMock()
        res_mock.text = 'Content'
        req_mock.Session().send.return_value = res_mock

        self.deps.append(req_mock)

        with AnyPath('http://example.com') as path:
            content = path.read_text()
        self.assertEqual(content, 'Content', 'Content was not created')
コード例 #3
0
 def test_sftp_scheme(self):
     ap = AnyPath('sftp://root@test:/test')
     self.assertEqual(type(ap), SftpPath)
コード例 #4
0
 def test_https_schemes(self):
     ap = AnyPath('hg+https://test')
     self.assertEqual(type(ap), HgPath)
コード例 #5
0
 def test_relative_scheme(self):
     ap = AnyPath('./test')
     self.assertEqual(type(ap), LocalPath)
コード例 #6
0
 def test_absolute_scheme(self):
     ap = AnyPath('/test')
     self.assertEqual(type(ap), LocalPath)
コード例 #7
0
 def test_file_scheme(self):
     ap = AnyPath('file://test')
     self.assertEqual(type(ap), LocalPath)
コード例 #8
0
 def test_http_scheme(self):
     ap = AnyPath('http://test')
     self.assertEqual(type(ap), HttpPath)
コード例 #9
0
 def test_git_scheme(self):
     ap = AnyPath('git://test')
     self.assertEqual(type(ap), GitPath)
コード例 #10
0
 def test_https_scheme(self):
     ap = AnyPath('git+https://test')
     self.assertEqual(type(ap), GitPath)
コード例 #11
0
 def create(self):
     for local, remote in self.value.items():
         ap = AnyPath(remote, self.parent.joinpath(local))
         ap.fetch()
         ap.close()
コード例 #12
0
from anypath.anypath import AnyPath, path_provider
from anypath.pathprovider.git import GitPath
from anypath.pathprovider.http import HttpPath

path_provider.add(HttpPath, GitPath)
path_provider.check_requirements()

with AnyPath('http://example.org') as path:
    content = path.read_text()
    print(len(content))

with AnyPath('git+https://github.com/vaubarth/anypath.git') as path:
    content = path.glob('*')
    print(list(content))
コード例 #13
0
 def test_hg(self):
     HgPath._check_dependencies = self.mocked_dependencies
     with patch('subprocess.Popen'):
         with AnyPath('hg+http://asdas') as path:
             self.assertTrue(path.parent.exists(), 'Path was not created')
コード例 #14
0
 def test_local(self):
     with AnyPath('./resources/localfile.txt') as path:
         content = path.read_text()
     self.assertEqual(content, 'Content', 'Content was not created')