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


Python MagicMock.version方法代码示例

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


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

示例1: setUp

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
    def setUp(self):
        # Mock resource model
        resource1 = MagicMock()
        resource1.name = 'Resource1'
        resource1.version = '1.0'
        resource1.description = 'Test resource 1'
        resource1.content_type = 'text/plain'
        resource1.state = 'created'
        resource1.open = False
        resource1.get_url.return_value = 'http://localhost/media/resources/resource1'

        resource2 = MagicMock()
        resource2.name = 'Resource2'
        resource2.version = '2.0'
        resource2.description = 'Test resource 2'
        resource2.content_type = 'text/plain'
        resource2.state = 'created'
        resource2.open = False
        resource2.get_url.return_value = 'http://localhost/media/resources/resource2'

        resource3 = MagicMock()
        resource3.name = 'Resource3'
        resource3.version = '2.0'
        resource3.description = 'Test resource 3'
        resource3.content_type = 'text/plain'
        resource3.state = 'created'
        resource3.open = True
        resource3.get_url.return_value = 'http://localhost/media/resources/resource3'

        resource4 = MagicMock()
        resource4.name = 'Resource4'
        resource4.version = '1.0'
        resource4.description = 'Test resource 4'
        resource4.content_type = 'text/plain'
        resource4.state = 'created'
        resource4.open = True
        resource4.get_url.return_value = 'http://localhost/media/resources/resource4'
        resource4.offerings = ['1111', '2222']

        resources_management.Resource = MagicMock()
        resources_management.Resource.objects.filter.return_value = [
            resource1,
            resource2,
            resource3,
            resource4
        ]
        self.user = MagicMock()
        self.org = MagicMock()
        self.user.userprofile.current_organization = self.org
开发者ID:gberryproject,项目名称:wstore,代码行数:51,代码来源:resource_tests.py

示例2: test_delete_missing

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
 def test_delete_missing(self):
     """ Deleting a missing package raises 400 """
     context = MagicMock()
     context.name = 'pkg1'
     context.version = '1.1'
     ret = api.delete_package(context, self.request)
     self.assertTrue(isinstance(ret, HTTPBadRequest))
开发者ID:johtso,项目名称:pypicloud,代码行数:9,代码来源:test_api.py

示例3: test_ChuteApi_get_chutes

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
def test_ChuteApi_get_chutes(ChuteStorage, ChuteContainer):
    update_manager = MagicMock()
    api = chute_api.ChuteApi(update_manager)

    request = MagicMock()

    container = MagicMock()
    container.getStatus.return_value = "running"
    ChuteContainer.return_value = container

    storage = MagicMock()
    ChuteStorage.return_value = storage

    chute = MagicMock()
    chute.environment = {}
    chute.name = "test"
    chute.state = "running"
    chute.resources = {}
    chute.version = 5
    chute.get_owner.return_value = "paradrop"

    storage.getChuteList.return_value = [chute]

    data = api.get_chutes(request)
    assert isinstance(data, basestring)

    result = json.loads(data)
    assert result[0]['name'] == chute.name
    assert result[0]['version'] == chute.version
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:31,代码来源:test_chute_api.py

示例4: test_ChuteApi_get_chute

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
def test_ChuteApi_get_chute(ChuteStorage, ChuteContainer):
    update_manager = MagicMock()
    api = chute_api.ChuteApi(update_manager)

    request = MagicMock()
    request.user = User.get_internal_user()

    container = MagicMock()
    container.getStatus.return_value = "running"
    ChuteContainer.return_value = container

    chute = MagicMock()
    chute.name = "test"
    chute.state = "running"
    chute.version = 5
    chute.environment = {}
    chute.resources = {}

    ChuteStorage.chuteList = {
        "test": chute
    }

    data = api.get_chute(request, chute.name)
    assert isinstance(data, basestring)

    result = json.loads(data)
    assert result['name'] == chute.name
    assert result['version'] == chute.version
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:30,代码来源:test_chute_api.py

示例5: test_create_request_with_right_context_params

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
    def test_create_request_with_right_context_params(self,
                                                      parent_breadcrumbs_from,
                                                      api_breadcrumb_filters,
                                                      settings):
        http_request = MagicMock()
        mock_api = MagicMock()
        mock_api.name = 'api_name'
        mock_api.version = '1.0.0.1'
        http_request.user.is_anonymous.return_value = False
        request_body = MagicMock()
        settings.TIME_ZONE = expected_timezone = MagicMock()

        request = api_request_builder.build_request(http_request=http_request,
                                                    url='candidates',
                                                    api=mock_api,
                                                    request_data={},
                                                    request_body=request_body)

        assert_that(request.context_params, has_entry('protocol', 'http'))
        assert_that(request.context_params, has_entry('url', 'candidates'))
        assert_that(request.context_params,
                    has_entry('timezone', expected_timezone))
        assert_that(request.context_params,
                    has_entry('api_version', mock_api.version))
        assert_that(request.context_params,
                    has_entry('api_name', mock_api.name))
开发者ID:Aplopio,项目名称:rip,代码行数:28,代码来源:test_api_request_builder.py

示例6: import_mock

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
 def import_mock(name, i_globals={}, i_locals={}, fromlist=[], level=-1, orig_import=__import__):
     # _psutil_linux and _psutil_posix are the C bindings; use a mock for those
     if name in ('_psutil_linux', '_psutil_posix') or level >= 1 and ('_psutil_linux' in fromlist or '_psutil_posix' in fromlist):
         m = MagicMock()
         # the import system will ask us for our own name
         m._psutil_linux = m
         m._psutil_posix = m
         # there's a version safety check in psutil/__init__.py; this skips it
         m.version = version
         return m
     return orig_import(name, i_globals, i_locals, fromlist, level)
开发者ID:MinerKasch,项目名称:dd-agent,代码行数:13,代码来源:test_process.py

示例7: test_get_version

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
def test_get_version(mock_glob, mock_require):
    require_mock = MagicMock()
    require_mock.version = 'netshowlibver'
    require_mock.location = '/var/me'
    mock_require.return_value = [require_mock]
    mock_glob.return_value = [
        '/var/me/linux']
    get_version()
    mock_require.assert_called_with('netshow-linux-lib')
    mock_glob.assert_called_with(
        '/var/me/../../../share/netshow-lib/providers/*')
开发者ID:CumulusNetworks,项目名称:netshow-core,代码行数:13,代码来源:test_netshowlib.py

示例8: test_process_command_cancel

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
async def test_process_command_cancel():
    self_ = MagicMock()
    self_.version = (3, 1)

    async def unsubscribe(*args):
        self_.check(*args)

    self_.unsubscribe = unsubscribe

    await StreamConnection._process_command(self_, b'CANCEL', b'data')

    self_.check.assert_called_once_with(b'data')
开发者ID:ereOn,项目名称:azmq,代码行数:14,代码来源:test_stream.py

示例9: test_process_command_subscribe

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
async def test_process_command_subscribe():
    self_ = MagicMock()
    self_.version = (3, 1)

    async def subscribe(*args):
        self_.check(*args)

    self_.subscribe = subscribe

    await StreamConnection._process_command(self_, b'SUBSCRIBE', b'data')

    self_.check.assert_called_once_with(b'data')
开发者ID:ereOn,项目名称:azmq,代码行数:14,代码来源:test_stream.py

示例10: create_fake_import

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
    def create_fake_import(self, name, version='1', check_items=True,
        install_status=InstallationStatuses.INSTALL_OK, uninstall_status=InstallationStatuses.UNINSTALL_OK):
        filenames = []
        filenames.append('%s.py' % FAKE_NAME1)

        import_mock = MagicMock()
        fake_package = MagicMock()
        fake_package.name = name
        fake_package.version = version
        fake_package.check_items.return_value = check_items
        fake_package.install.return_value = install_status
        fake_package.uninstall.return_value = uninstall_status
        import_mock.Formula.return_value = fake_package

        return filenames, import_mock
开发者ID:Gr1N,项目名称:procyon,代码行数:17,代码来源:test_pkg.py

示例11: _mock_resource

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
    def _mock_resource(self, info, provider):
        # Mock resource model
        resource = MagicMock()
        resource.pk = info['pk']
        resource.provider = provider
        resource.version = info['version']
        resource.content_type = info['content_type']
        resource.state = info['state']
        resource.download_link = info['download_link']
        resource.resource_type = info['type']
        resource.meta_info = {}

        resource.get_url.return_value = info['download_link']
        resource.get_uri.return_value = info['uri']

        return resource
开发者ID:FIWARE-TMForum,项目名称:business-ecosystem-charging-backend,代码行数:18,代码来源:asset_manager_tests.py

示例12: test_prepare_environment

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
def test_prepare_environment(core):
    chute = MagicMock()
    chute.name = "test"
    chute.version = 5
    chute.get_environment.return_value = {"CHUTE_VARIABLE": "test"}

    core.info.pdid = 'halo42'

    update = MagicMock()
    update.new = chute

    service = MagicMock()
    service.environment = {"CUSTOM_VARIABLE": 42}

    env = dockerapi.prepare_environment(update, service)
    assert env['PARADROP_CHUTE_NAME'] == chute.name
    assert env['PARADROP_CHUTE_VERSION'] == chute.version
    assert env['PARADROP_ROUTER_ID'] == core.info.pdid
    assert env['CUSTOM_VARIABLE'] == 42
    assert env['CHUTE_VARIABLE'] == 'test'
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:22,代码来源:test_dockerapi.py

示例13: test_create_request_with_right_request_params

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
    def test_create_request_with_right_request_params(self,
                                                      parent_breadcrumbs_from,
                                                      breadcrumb_filters,
                                                      settings):
        http_request = MagicMock()
        mock_api = MagicMock()
        mock_api.name = 'api_name'
        mock_api.version = '1.0.0.1'
        mock_user = http_request.user
        request_body = MagicMock()
        http_request.user.is_anonymous.return_value = False
        breadcrumb_filters.return_value = expected_req_params = {'bar': 'baz'}

        request = api_request_builder.build_request(http_request=http_request,
                                                    url='candidates',
                                                    api=mock_api,
                                                    request_data={},
                                                    request_body=request_body)
        assert_that(request.user, equal_to(mock_user))
        assert_that(request.request_params, equal_to(expected_req_params))
开发者ID:Aplopio,项目名称:rip,代码行数:22,代码来源:test_api_request_builder.py

示例14: test_migration_removed

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
    def test_migration_removed(self, mock_get_packages, mock_getLogger):
        """
        ensure that if a migration raises the MigrationRemovedError, it bubbles up.
        """
        mock_package = MagicMock()
        mock_package.current_version = 6
        mock_package.latest_available_version = 7
        mock_package.name = 'foo'
        mock_migration = MagicMock()
        mock_migration.version = 7
        mock_package.unapplied_migrations = [mock_migration]
        e = models.MigrationRemovedError('0006', '1.2.0', '1.1.0', 'foo')
        mock_package.apply_migration.side_effect = e
        mock_get_packages.return_value = [mock_package]
        options = MagicMock()
        options.dry_run = False

        with self.assertRaises(models.MigrationRemovedError) as assertion:
            manage.migrate_database(options)

        self.assertTrue(assertion.exception is e)
开发者ID:maxamillion,项目名称:pulp,代码行数:23,代码来源:test_manage.py

示例15: setUp

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import version [as 别名]
    def setUp(self):
        # Mock resource model
        resource1 = MagicMock()
        resource1.name = 'Resource1'
        resource1.version = '1.0'
        resource1.description = 'Test resource 1'
        resource1.content_type = 'text/plain'
        resource1.state = 'created'
        resource1.open = False
        resource1.get_url.return_value = 'http://localhost/media/resources/resource1'
        resource1.resource_type = 'API'
        resource1.meta_info = {}

        resource2 = MagicMock()
        resource2.name = 'Resource2'
        resource2.version = '2.0'
        resource2.description = 'Test resource 2'
        resource2.content_type = 'text/plain'
        resource2.state = 'created'
        resource2.open = False
        resource2.get_url.return_value = 'http://localhost/media/resources/resource2'
        resource2.resource_type = 'API'
        resource2.meta_info = {}

        resource3 = MagicMock()
        resource3.name = 'Resource3'
        resource3.version = '2.0'
        resource3.description = 'Test resource 3'
        resource3.content_type = 'text/plain'
        resource3.state = 'created'
        resource3.open = True
        resource3.get_url.return_value = 'http://localhost/media/resources/resource3'
        resource3.resource_type = 'API'
        resource3.meta_info = {}

        resource4 = MagicMock()
        resource4.name = 'Resource4'
        resource4.version = '1.0'
        resource4.description = 'Test resource 4'
        resource4.content_type = 'text/plain'
        resource4.state = 'created'
        resource4.open = True
        resource4.get_url.return_value = 'http://localhost/media/resources/resource4'
        resource4.resource_type = 'API'
        resource4.offerings = ['1111', '2222']
        resource4.meta_info = {}

        resources_management.Resource = MagicMock()

        def resource_filter(provider=None, open=None):
            if provider != self.org:
                return []

            if open is None:
                result = [
                    resource1,
                    resource2,
                    resource3,
                    resource4
                ]
            elif not open:
                result = [
                    resource1,
                    resource2
                ]
            else:
                result = [
                    resource3,
                    resource4
                ]
            return result

        resources_management.Resource.objects.filter = resource_filter

        self.user = MagicMock()
        self.org = MagicMock()
        self.user.userprofile.current_organization = self.org
开发者ID:Fiware,项目名称:apps.Wstore,代码行数:79,代码来源:resource_tests.py


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