How to use the ipfshttpclient.Client function in ipfshttpclient

To help you get started, we’ve selected a few ipfshttpclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs / py-ipfs-http-client / test / functional / tests.py View on Github external
def setUp(self):
        self.http_client = ipfshttpclient.Client()
        self._olddir = os.getcwd()
        os.chdir(HERE)
github ipfs / py-ipfs-http-client / test / functional / tests.py View on Github external
def test_assert_version(self):
        # Minimum required version
        ipfshttpclient.assert_version("0.1.0", "0.1.0", "0.2.0")

        # Too high version
        with self.assertRaises(ipfshttpclient.exceptions.VersionMismatch):
            ipfshttpclient.assert_version("0.2.0", "0.1.0", "0.2.0")

        # Too low version
        with self.assertRaises(ipfshttpclient.exceptions.VersionMismatch):
            ipfshttpclient.assert_version("0.0.5", "0.1.0", "0.2.0")

@skipIfOffline()
class IpfsHttpClientTest(unittest.TestCase):

    http_client = ipfshttpclient.Client()

    fake = [{'Hash': u'QmQcCtMgLVwvMQGu6mvsRYLjwqrZJcYtH4mboM9urWW9vX',
             'Name': 'fake_dir/fsdfgh'},
            {'Hash': u'QmYAhvKYu46rh5NcHzeu6Bhc7NG9SqkF9wySj2jvB74Rkv',
             'Name': 'fake_dir/popoiopiu'},
            {'Hash': u'QmeMbJSHNCesAh7EeopackUdjutTJznum1Fn7knPm873Fe',
             'Name': 'fake_dir/test3/ppppoooooooooo'},
            {'Hash': u'QmRphRr6ULDEj7YnXpLdnxhnPiVjv5RDtGX3er94Ec6v4Q',
             'Name': 'fake_dir/test3'},
            {'Hash': u'QmNuvmuFeeWWpxjCQwLkHshr8iqhGLWXFzSGzafBeawTTZ',
             'Name': 'fake_dir/test2/llllg'},
            {'Hash': u'Qmb1NPqPzdHCMvHRfCkk6TWLcnpGJ71KnafacCMm6TKLcD',
             'Name': 'fake_dir/test2/fssdf'},
            {'Hash': u'QmX1dd5DtkgoiYRKaPQPTCtXArUu4jEZ62rJBUcd5WhxAZ',
             'Name': 'fake_dir/test2'},
            {'Hash': u'QmRphRr6ULDEj7YnXpLdnxhnPiVjv5RDtGX3er94Ec6v4Q',
github ipfs / py-ipfs-http-client / test / unit / test_client.py View on Github external
def test_client_session_param():
	client = ipfshttpclient.Client(session=True)
	assert client._client._session is not None
	try:
		with pytest.raises(Exception):
			with client:
				pass  # Should fail because a session is already open
		assert client._client._session is not None
	finally:
		client.close()
	assert client._client._session is None
github ipfs / py-ipfs-http-client / test / functional / tests.py View on Github external
def setUp(self):
        self.http_client = ipfshttpclient.Client()
github ipfs / py-ipfs-http-client / test / functional / tests.py View on Github external
def setUp(self):
        self.http_client = ipfshttpclient.Client()
        self.pid = int(os.environ["PY_IPFS_HTTP_CLIENT_TEST_DAEMON_PID"])
github ipfs / py-ipfs-http-client / test / functional / tests.py View on Github external
def setUp(self):
        self.http_client = ipfshttpclient.Client()
        self.multihash = 'QmYA2fn8cMbVWo4v95RwcwJVyQsNtnEwHerfWR8UNtEwoE'
        self.content_size = 248
github ipfs / py-ipfs-http-client / test / functional / tests.py View on Github external
def setUp(self):
        self.http_client = ipfshttpclient.Client()
        self._olddir = os.getcwd()
        os.chdir(HERE)
        # Add a resource to get the stats for.
        self.resource = self.http_client.add_str('Mary had a little lamb')
github AuHau / ipfs-publish / tests / unit / test_publishing.py View on Github external
def test_publish_rm_old_pin(self, mocker):
        mocker.patch.object(git.Repo, 'clone_from')
        mocker.patch.object(shutil, 'rmtree')

        ipfs_client_mock = mocker.Mock(spec=ipfshttpclient.Client)
        ipfs_client_mock.add.return_value = [{'Hash': 'some-hash'}]

        mocker.patch.object(ipfshttpclient, 'connect')
        ipfshttpclient.connect.return_value = ipfs_client_mock

        repo: publishing.GenericRepo = factories.RepoFactory(last_ipfs_addr='some_hash')
        repo.publish_repo()

        ipfs_client_mock.pin.rm.assert_called_once_with('some_hash')
github ipfs / py-ipfs-http-client / test / unit / test_client.py View on Github external
def test_client_session_context():
	client = ipfshttpclient.Client()
	assert client._client._session is None
	with client:
		assert client._client._session is not None
	assert client._client._session is None
github ipfs / py-ipfs-http-client / ipfsapi / client / __init__.py View on Github external
:class:`~ipfsapi.Client` class.

	Returns
	-------
		~ipfsapi.Client
	"""
	# Create client instance
	client = Client(host, port, base, chunk_size, **defaults)

	# Query version number from daemon and validate it
	assert_version(client.version()['Version'])

	return client


class Client(ipfshttpclient.Client):
	# Aliases for previous method names
	key_gen    = base.DeprecatedMethodProperty("key", "gen")
	key_list   = base.DeprecatedMethodProperty("key", "list")
	key_rename = base.DeprecatedMethodProperty("key", "rename")
	key_rm     = base.DeprecatedMethodProperty("key", "rm")

	block_get  = base.DeprecatedMethodProperty("block", "get")
	block_put  = base.DeprecatedMethodProperty("block", "put")
	block_stat = base.DeprecatedMethodProperty("block", "stat")

	files_cp    = base.DeprecatedMethodProperty("files", "cp")
	files_ls    = base.DeprecatedMethodProperty("files", "ls")
	files_mkdir = base.DeprecatedMethodProperty("files", "mkdir")
	files_stat  = base.DeprecatedMethodProperty("files", "stat")
	files_rm    = base.DeprecatedMethodProperty("files", "rm")
	files_read  = base.DeprecatedMethodProperty("files", "read")