当前位置: 首页>>代码示例>>Python>>正文


Python promise.Promise方法代码示例

本文整理汇总了Python中promise.Promise方法的典型用法代码示例。如果您正苦于以下问题:Python promise.Promise方法的具体用法?Python promise.Promise怎么用?Python promise.Promise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在promise的用法示例。


在下文中一共展示了promise.Promise方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_load_many_dataset

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_many_dataset(self, fixture_working_dir):
        im = InventoryManager(fixture_working_dir[0])
        im.create_dataset("default", "default", "dataset1", storage_type="gigantum_object_v1",
                          description="a dataset")
        im.create_dataset("default", "default", "dataset2", storage_type="gigantum_object_v1",
                          description="another dataset")
        im.create_dataset("default", "tester_user", "dataset3", storage_type="gigantum_object_v1",
                          description="yet another dataset")

        loader = FetchLoader()

        keys = ["dataset&default&default&dataset1", "dataset&default&default&dataset2",
                "dataset&default&tester_user&dataset3"]
        promise1 = loader.load_many(keys)
        assert isinstance(promise1, Promise)
        promise1.get() 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:18,代码来源:test_dataloader_fetch.py

示例2: test_load_many

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_many(self, fixture_working_dir):
        """Test loading many labbooks"""
        im = InventoryManager(fixture_working_dir[0])
        im.create_dataset("default", "default", "dataset1", storage_type="gigantum_object_v1",
                          description="a dataset")
        im.create_dataset("default", "default", "dataset2", storage_type="gigantum_object_v1",
                          description="another dataset")
        im.create_dataset("default", "tester_user", "dataset3", storage_type="gigantum_object_v1",
                          description="yet another dataset")

        loader = DatasetLoader()

        keys = ["default&default&dataset1", "default&default&dataset2", "default&tester_user&dataset3"]
        promise1 = loader.load_many(keys)
        assert isinstance(promise1, Promise)

        ds_list = promise1.get()
        assert ds_list[0].name == "dataset1"
        assert ds_list[0].description == "a dataset"
        assert ds_list[1].name == "dataset2"
        assert ds_list[1].description == "another dataset"
        assert ds_list[2].name == "dataset3"
        assert ds_list[2].description == "yet another dataset" 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:25,代码来源:test_dataloader_dataset.py

示例3: test_load_many

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_many(self, fixture_working_dir):
        """Test loading many labbooks"""
        im = InventoryManager(fixture_working_dir[0])
        im.create_labbook("default", "default", "labbook1", description="my first labbook1")
        im.create_labbook("default", "default", "labbook2", description="my first labbook2")
        im.create_labbook("default", "test3", "labbook2", description="my first labbook3")

        loader = LabBookLoader()

        keys = ["default&default&labbook1", "default&default&labbook2", "default&test3&labbook2"]
        promise1 = loader.load_many(keys)
        assert isinstance(promise1, Promise)

        lb_list = promise1.get()
        assert lb_list[0].name == "labbook1"
        assert lb_list[0].description == "my first labbook1"
        assert lb_list[1].name == "labbook2"
        assert lb_list[1].description == "my first labbook2"
        assert lb_list[2].name == "labbook2"
        assert lb_list[2].description == "my first labbook3" 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:22,代码来源:test_dataloader_labbook.py

示例4: test_load_many_apt

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_many_apt(self, build_image_for_jupyterlab):
        lb, username = build_image_for_jupyterlab[0], build_image_for_jupyterlab[5]
        keys = ["apt&curl", "apt&vim"]
        loader = PackageDataloader(keys, lb, username)
        promise1 = loader.load_many(keys)
        assert isinstance(promise1, Promise)

        version_list = promise1.get()
        assert len(version_list) == 2
        assert isinstance(version_list[0], PackageMetadata) is True
        assert 'ubuntu' in version_list[0].latest_version
        assert version_list[0].description == 'command line tool for transferring data with URL syntax'
        assert version_list[0].docs_url is None
        assert version_list[0].package == 'curl'
        assert version_list[0].package_manager == 'apt'

        assert 'ubuntu' in version_list[1].latest_version
        assert version_list[1].description == 'Vi IMproved - enhanced vi editor'
        assert version_list[1].docs_url is None
        assert version_list[1].package == 'vim'
        assert version_list[1].package_manager == 'apt' 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:23,代码来源:test_dataloader_package.py

示例5: test_load_many_conda2

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_many_conda2(self, build_image_for_jupyterlab):
        """Test loading many conda2 packages"""
        lb, username = build_image_for_jupyterlab[0], build_image_for_jupyterlab[5]
        keys = ["conda2&cdutil", "conda2&python-coveralls", "conda2&nltk"]
        loader = PackageDataloader(keys, lb, username)
        promise1 = loader.load_many(keys)
        assert isinstance(promise1, Promise)

        version_list = promise1.get()
        assert len(version_list) == 3

        assert version_list[0].latest_version == "8.2"
        assert version_list[0].description == 'A set of tools to manipulate climate data'
        assert version_list[0].docs_url == 'http://anaconda.org/conda-forge/cdutil'

        assert version_list[1].latest_version == "2.9.3"
        assert version_list[1].description == 'Python interface to coveralls.io API\\n'
        assert version_list[1].docs_url == 'http://anaconda.org/conda-forge/python-coveralls'

        assert version_list[2].latest_version == "3.4.4"
        assert version_list[2].description == 'Natural Language Toolkit'
        assert version_list[2].docs_url == 'http://www.nltk.org/' 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:24,代码来源:test_dataloader_package.py

示例6: resolve

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def resolve(self, msg):
        """Resolve an open JSONRPC request.

        Takes a JSONRPC result message and passes it to either the
        on_fulfilled handler or the on_rejected handler of the Promise.

        :param msg: JSONRPC result message
        :returns: Nothing
        :rtype: None

        """
        if msg['id'] in self._promises:
            try:
                if msg['error'] is not None:
                    self._promises[msg['id']].reject(Exception(msg['error']))
                else:
                    self._promises[msg['id']].fulfill(msg['result'])

            except Exception as e:
                raise e
        else:
            self.log.warn("Could not find promise with id %s" % msg['id']) 
开发者ID:OpenGeoscience,项目名称:geonotebook,代码行数:24,代码来源:kernel.py

示例7: test_social_auth_thenable

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_social_auth_thenable(self, *args):

        @decorators.social_auth
        def wrapped(cls, root, info, provider, *args):
            return Promise()

        result = wrapped(TestCase, None, self.info(), 'google-oauth2', 'token')

        self.assertTrue(is_thenable(result)) 
开发者ID:flavors,项目名称:django-graphql-social-auth,代码行数:11,代码来源:test_decorators.py

示例8: test_load_one_dataset

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_one_dataset(self, fixture_working_dir):
        im = InventoryManager(fixture_working_dir[0])
        im.create_dataset("default", "default", "dataset1", storage_type="gigantum_object_v1",
                          description="a dataset")
        im.create_dataset("default", "default", "dataset2", storage_type="gigantum_object_v1",
                          description="another dataset")
        loader = FetchLoader()

        key = f"dataset&default&default&dataset1"
        promise1 = loader.load(key)
        assert isinstance(promise1, Promise)
        assert promise1.get() is None 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:14,代码来源:test_dataloader_fetch.py

示例9: test_load_one_labbook

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_one_labbook(self, fixture_working_dir):
        im = InventoryManager(fixture_working_dir[0])
        im.create_labbook("default", "default", "lb1", description="a project")
        im.create_labbook("default", "default", "lb2", description="a project")
        loader = FetchLoader()

        key = "labbook&default&default&lb1"
        promise1 = loader.load(key)
        assert isinstance(promise1, Promise)
        assert promise1.get() is None 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:12,代码来源:test_dataloader_fetch.py

示例10: test_load_labbook_multiple

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_labbook_multiple(self, fixture_working_dir):
        im = InventoryManager(fixture_working_dir[0])
        im.create_labbook("default", "default", "lb1", description="a project")
        im.create_labbook("default", "default", "lb2", description="a project")
        loader = FetchLoader()

        key = "labbook&default&default&lb1"
        promise1 = loader.load(key)
        promise2 = loader.load(key)
        promise3 = loader.load(key)
        assert isinstance(promise1, Promise)
        assert promise1.get() is None
        assert promise2.get() is None
        assert promise3.get() is None 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:16,代码来源:test_dataloader_fetch.py

示例11: test_load_many_labbook

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_many_labbook(self, fixture_working_dir):
        im = InventoryManager(fixture_working_dir[0])
        im.create_labbook("default", "default", "lb1", description="a project")
        im.create_labbook("default", "default", "lb2", description="a project")
        im.create_labbook("default", "default", "lb3", description="a project")

        loader = FetchLoader()

        keys = ["labbook&default&default&lb1", "labbook&default&default&lb2",
                "labbook&default&default&lb3"]
        promise1 = loader.load_many(keys)
        assert isinstance(promise1, Promise)
        promise1.get() 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:15,代码来源:test_dataloader_fetch.py

示例12: test_load_one

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_one(self, fixture_working_dir):
        """Test loading 1 labbook"""
        im = InventoryManager(fixture_working_dir[0])
        im.create_labbook("default", "default", "labbook1", description="my first labbook1")
        im.create_labbook("default", "default", "labbook2", description="my first labbook2")
        loader = LabBookLoader()

        key = f"default&default&labbook1"
        promise1 = loader.load(key)
        assert isinstance(promise1, Promise)

        lb = promise1.get()
        assert lb.name == "labbook1"
        assert lb.description == "my first labbook1" 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:16,代码来源:test_dataloader_labbook.py

示例13: test_load_one_pip

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_one_pip(self, build_image_for_jupyterlab):
        """Test loading 1 package"""

        key = "pip&gtmunit1"
        lb, username = build_image_for_jupyterlab[0], build_image_for_jupyterlab[5]

        loader = PackageDataloader([key], lb, username)
        promise1 = loader.load(key)
        assert isinstance(promise1, Promise)

        pkg = promise1.get()
        assert isinstance(pkg, PackageMetadata) is True
        assert pkg.description == 'Package 1 for Gigantum Client unit testing.'
        assert pkg.docs_url == 'https://github.com/gigantum/gigantum-client'
        assert pkg.latest_version == '0.12.4' 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:17,代码来源:test_dataloader_package.py

示例14: test_load_many_conda

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_many_conda(self, build_image_for_jupyterlab):
        """Test loading many conda3 packages"""
        lb, username = build_image_for_jupyterlab[0], build_image_for_jupyterlab[5]
        keys = ["conda3&cdutil", "conda3&python-coveralls", "conda3&nltk", "conda3&asdfasdffghdfdasfgh"]
        loader = PackageDataloader(keys, lb, username)
        promise1 = loader.load_many(keys)
        assert isinstance(promise1, Promise)

        version_list = promise1.get()
        assert len(version_list) == 4

        assert version_list[0].latest_version == "8.2"
        assert version_list[0].description == 'A set of tools to manipulate climate data'
        assert version_list[0].docs_url == 'http://anaconda.org/conda-forge/cdutil'

        assert version_list[1].latest_version == "2.9.3"
        assert version_list[1].description == 'Python interface to coveralls.io API\\n'
        assert version_list[1].docs_url == 'http://anaconda.org/conda-forge/python-coveralls'

        assert version_list[2].latest_version == "3.4.4"
        assert version_list[2].description == 'Natural Language Toolkit'
        assert version_list[2].docs_url == 'http://www.nltk.org/'

        assert version_list[3].latest_version is None
        assert version_list[3].description is None
        assert version_list[3].docs_url is None 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:28,代码来源:test_dataloader_package.py

示例15: test_load_many_mixed

# 需要导入模块: import promise [as 别名]
# 或者: from promise import Promise [as 别名]
def test_load_many_mixed(self, build_image_for_jupyterlab):
        """Test loading many labbooks"""
        lb, username = build_image_for_jupyterlab[0], build_image_for_jupyterlab[5]
        keys = ["conda3&cdutil", "pip&gtmunit1", "pip&gtmunit2", "conda3&nltk", 'apt&curl']
        loader = PackageDataloader(keys, lb, username)
        promise1 = loader.load_many(keys)
        assert isinstance(promise1, Promise)

        version_list = promise1.get()
        assert len(version_list) == 5
        assert version_list[0].latest_version == "8.2"
        assert version_list[0].description == 'A set of tools to manipulate climate data'
        assert version_list[0].docs_url == 'http://anaconda.org/conda-forge/cdutil'

        assert version_list[1].latest_version == '0.12.4'
        assert version_list[1].description == 'Package 1 for Gigantum Client unit testing.'
        assert version_list[1].docs_url == 'https://github.com/gigantum/gigantum-client'

        assert version_list[2].latest_version == '12.2'
        assert version_list[2].description == 'Package 1 for Gigantum Client unit testing.'
        assert version_list[2].docs_url == 'https://github.com/gigantum/gigantum-client'

        assert version_list[3].latest_version == '3.4.4'
        assert version_list[3].description == 'Natural Language Toolkit'
        assert version_list[3].docs_url == 'http://www.nltk.org/'

        assert version_list[4].latest_version is not None
        assert version_list[4].description == 'command line tool for transferring data with URL syntax'
        assert version_list[4].docs_url is None 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:31,代码来源:test_dataloader_package.py


注:本文中的promise.Promise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。