當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。