• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python matchers.MatchesStructure类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中testtools.matchers.MatchesStructure的典型用法代码示例。如果您正苦于以下问题:Python MatchesStructure类的具体用法?Python MatchesStructure怎么用?Python MatchesStructure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_values

 def test_values(self):
     task = self.factory.makeBugTask()
     with person_logged_in(task.product.owner):
         task.transitionToAssignee(self.factory.makePerson())
         task.transitionToMilestone(
             self.factory.makeMilestone(product=task.product),
             task.product.owner)
         task.bug.markAsDuplicate(self.factory.makeBug())
     flat = self.getBugTaskFlat(task)
     self.assertThat(
         flat,
         MatchesStructure.byEquality(
             bugtask=task.id,
             bug=task.bug.id,
             datecreated=task.datecreated.replace(tzinfo=None),
             duplicateof=task.bug.duplicateof.id,
             bug_owner=task.bug.owner.id,
             information_type=task.bug.information_type.value,
             date_last_updated=task.bug.date_last_updated.replace(
                 tzinfo=None),
             heat=task.bug.heat,
             product=task.product.id,
             productseries=None,
             distribution=None,
             distroseries=None,
             sourcepackagename=None,
             status=task.status.value,
             importance=task.importance.value,
             assignee=task.assignee.id,
             milestone=task.milestone.id,
             owner=task.owner.id,
             active=task.product.active,
             access_policies=None,
             access_grants=None))
     self.assertIsNot(None, flat.fti)
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:35,代码来源:test_bugtaskflat_triggers.py


示例2: test_updateWorkItems_merges_with_existing_ones

    def test_updateWorkItems_merges_with_existing_ones(self):
        spec = self.factory.makeSpecification(
            product=self.factory.makeProduct())
        login_person(spec.owner)
        # Create two work-items in our database.
        wi1_data = self._createWorkItemAndReturnDataDict(spec)
        wi2_data = self._createWorkItemAndReturnDataDict(spec)
        self.assertEqual(2, len(spec.work_items))

        # These are the work items we'll be inserting.
        new_wi1_data = dict(
            title=u'Some Title', status=SpecificationWorkItemStatus.TODO,
            assignee=None, milestone=None)
        new_wi2_data = dict(
            title=u'Other title', status=SpecificationWorkItemStatus.TODO,
            assignee=None, milestone=None)

        # We want to insert the two work items above in the first and third
        # positions respectively, so the existing ones to be moved around
        # (e.g. have their sequence updated).
        work_items = [new_wi1_data, wi1_data, new_wi2_data, wi2_data]
        spec.updateWorkItems(work_items)

        # Update our data dicts with the sequences we expect the work items in
        # our DB to have.
        new_wi1_data['sequence'] = 0
        wi1_data['sequence'] = 1
        new_wi2_data['sequence'] = 2
        wi2_data['sequence'] = 3

        self.assertEqual(4, len(spec.work_items))
        for data, obj in zip(work_items, list(spec.work_items)):
            self.assertThat(obj, MatchesStructure.byEquality(**data))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:33,代码来源:test_specification.py


示例3: test__Version_read

 def test__Version_read(self):
     session = bones.SessionAPI(self.description)
     action = session.Version.read
     self.assertThat(action, MatchesStructure.byEquality(
         name="read", fullname="Version.read", method="GET",
         handler=session.Version, is_restful=True, op=None,
     ))
开发者ID:alburnum,项目名称:alburnum-maas-client,代码行数:7,代码来源:test_bones.py


示例4: _dup_work_items_set_up

    def _dup_work_items_set_up(self):
        spec = self.factory.makeSpecification(
            product=self.factory.makeProduct())
        login_person(spec.owner)
        # Create two work-items in our database.
        wi1_data = self._createWorkItemAndReturnDataDict(spec)
        wi2_data = self._createWorkItemAndReturnDataDict(spec)

        # Create a duplicate and a near duplicate, insert into DB.
        new_wi1_data = wi2_data.copy()
        new_wi2_data = new_wi1_data.copy()
        new_wi2_data['status'] = SpecificationWorkItemStatus.DONE
        work_items = [new_wi1_data, wi1_data, new_wi2_data, wi2_data]
        spec.updateWorkItems(work_items)

        # Update our data dicts with the sequences to match data in DB
        new_wi1_data['sequence'] = 0
        wi1_data['sequence'] = 1
        new_wi2_data['sequence'] = 2
        wi2_data['sequence'] = 3

        self.assertEqual(4, len(spec.work_items))
        for data, obj in zip(work_items, spec.work_items):
            self.assertThat(obj, MatchesStructure.byEquality(**data))

        return spec, work_items
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:26,代码来源:test_specification.py


示例5: test_WithNativeArgs

 def test_WithNativeArgs(self):
     # Options can be passed as the string representations of the
     # types the script wants them in.
     options = parse_opts([
         '--submitter=1',
         '--reviewer=2',
         '--id=3',
         '--id=4',
         '--potemplate=5',
         '--language=te',
         '--not-language',
         '--is-current-ubuntu=True',
         '--is-current-upstream=False',
         '--msgid=Hello',
         '--origin=1',
         '--force',
         ])
     self.assertThat(options, MatchesStructure.byEquality(
         submitter=1,
         reviewer=2,
         ids=[3, 4],
         potemplate=5,
         language='te',
         not_language=True,
         is_current_ubuntu=True,
         is_current_upstream=False,
         origin=1,
         force=True))
开发者ID:vitaminmoo,项目名称:unnaturalcode,代码行数:28,代码来源:test_remove_translations.py


示例6: test_if_message_given_message

 def test_if_message_given_message(self):
     # Annotate.if_message returns an annotated version of the matcher if a
     # message is provided.
     matcher = Equals(1)
     expected = Annotate("foo", matcher)
     annotated = Annotate.if_message("foo", matcher)
     self.assertThat(annotated, MatchesStructure.fromExample(expected, "annotation", "matcher"))
开发者ID:brantlk,项目名称:testtools,代码行数:7,代码来源:test_higherorder.py


示例7: test_merge_accesspolicygrants_conflicts

    def test_merge_accesspolicygrants_conflicts(self):
        # Conflicting AccessPolicyGrants are deleted.
        policy = self.factory.makeAccessPolicy()

        person = self.factory.makePerson()
        person_grantor = self.factory.makePerson()
        person_grant = self.factory.makeAccessPolicyGrant(
            grantee=person, grantor=person_grantor, policy=policy)
        person_grant_date = person_grant.date_created

        duplicate = self.factory.makePerson()
        duplicate_grantor = self.factory.makePerson()
        self.factory.makeAccessPolicyGrant(
            grantee=duplicate, grantor=duplicate_grantor, policy=policy)

        self._do_premerge(duplicate, person)
        with person_logged_in(person):
            self._do_merge(duplicate, person)

        # Only one grant for the policy exists: the retained person's.
        source = getUtility(IAccessPolicyGrantSource)
        self.assertThat(
            source.findByPolicy([policy]).one(),
            MatchesStructure.byEquality(
                policy=policy,
                grantee=person,
                date_created=person_grant_date))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:27,代码来源:test_personmerge.py


示例8: test__Machines_deployment_status

 def test__Machines_deployment_status(self):
     session = bones.SessionAPI(self.description, ("a", "b", "c"))
     action = session.Machines.deployment_status
     self.assertThat(action, MatchesStructure.byEquality(
         name="deployment_status", fullname="Machines.deployment_status",
         method="GET", handler=session.Machines, is_restful=False,
         op="deployment_status",
     ))
开发者ID:alburnum,项目名称:alburnum-maas-client,代码行数:8,代码来源:test_bones.py


示例9: test_initialisation

 def test_initialisation(self):
     server_address = factory.getRandomString()
     shared_key = factory.getRandomString()
     shell = Omshell(server_address, shared_key)
     self.assertThat(
         shell, MatchesStructure.byEquality(
             server_address=server_address,
             shared_key=shared_key))
开发者ID:deepakhajare,项目名称:maas,代码行数:8,代码来源:test_omshell.py


示例10: test_toTerm_empty_description

 def test_toTerm_empty_description(self):
     archive = self.factory.makeArchive(description='')
     vocab = PPAVocabulary()
     term = vocab.toTerm(archive)
     self.assertThat(term, MatchesStructure.byEquality(
         value=archive,
         token='%s/%s' % (archive.owner.name, archive.name),
         title='No description available'))
开发者ID:vitaminmoo,项目名称:unnaturalcode,代码行数:8,代码来源:test_vocabularies.py


示例11: test_getConfigs_maps_distro_and_purpose_to_matching_config

 def test_getConfigs_maps_distro_and_purpose_to_matching_config(self):
     distro = self.makeDistroWithPublishDirectory()
     script = self.makeScript(distro)
     script.setUp()
     reference_config = getPubConfig(distro.main_archive)
     config = script.getConfigs()[distro][ArchivePurpose.PRIMARY]
     self.assertThat(
         config, MatchesStructure.fromExample(
             reference_config, 'temproot', 'distroroot', 'archiveroot'))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:9,代码来源:test_publish_ftpmaster.py


示例12: test_getTermByToken

 def test_getTermByToken(self):
     vocab = InformationTypeVocabulary([InformationType.PUBLIC])
     self.assertThat(
         vocab.getTermByToken('PUBLIC'),
         MatchesStructure.byEquality(
             value=InformationType.PUBLIC,
             token='PUBLIC',
             title='Public',
             description=InformationType.PUBLIC.description))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:9,代码来源:test_information_type_vocabulary.py


示例13: test_DDEBsGetOverrideFromDEBs

    def test_DDEBsGetOverrideFromDEBs(self):
        # Test the basic case ensuring that DDEB files always match the
        # DEB's overrides.
        deb = self.addFile("foo_1.0_i386.deb", "main/devel", "extra")
        ddeb = self.addFile("foo-dbgsym_1.0_i386.ddeb", "universe/web", "low")
        self.assertMatchDDEBErrors([])
        self.upload._overrideDDEBSs()

        self.assertThat(ddeb, MatchesStructure.fromExample(deb, "component_name", "section_name", "priority_name"))
开发者ID:vitaminmoo,项目名称:unnaturalcode,代码行数:9,代码来源:test_nascentupload.py


示例14: test_productseries_target

 def test_productseries_target(self):
     ps = self.factory.makeProductSeries()
     task = self.factory.makeBugTask(target=ps)
     flat = self.getBugTaskFlat(task)
     self.assertThat(
         flat,
         MatchesStructure.byEquality(
             product=None, productseries=ps.id, distribution=None,
             distroseries=None, sourcepackagename=None, active=True))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:9,代码来源:test_bugtaskflat_triggers.py


示例15: test_sourcepackage_target

 def test_sourcepackage_target(self):
     sp = self.factory.makeSourcePackage()
     task = self.factory.makeBugTask(target=sp)
     flat = self.getBugTaskFlat(task)
     self.assertThat(
         flat,
         MatchesStructure.byEquality(
             product=None, productseries=None, distribution=None,
             distroseries=sp.distroseries.id,
             sourcepackagename=sp.sourcepackagename.id, active=True))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:10,代码来源:test_bugtaskflat_triggers.py


示例16: test_delete_duplicate_work_item

    def test_delete_duplicate_work_item(self):
        spec, work_items = self._dup_work_items_set_up()

        # Delete a duplicate work item
        work_items.pop()
        spec.updateWorkItems(work_items)

        self.assertEqual(3, len(spec.work_items))
        for data, obj in zip(work_items, list(spec.work_items)):
            self.assertThat(obj, MatchesStructure.byEquality(**data))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:10,代码来源:test_specification.py


示例17: test_creates_commissioning_script

 def test_creates_commissioning_script(self):
     content = factory.getRandomString()
     name = factory.make_name('filename')
     uploaded_file = SimpleUploadedFile(content=content, name=name)
     form = CommissioningScriptForm(files={'content': uploaded_file})
     self.assertTrue(form.is_valid(), form._errors)
     form.save()
     new_script = CommissioningScript.objects.get(name=name)
     self.assertThat(
         new_script,
         MatchesStructure.byEquality(name=name, content=content))
开发者ID:deepakhajare,项目名称:maas,代码行数:11,代码来源:test_forms.py


示例18: test_new_creates_nodegroup_with_given_dhcp_settings

 def test_new_creates_nodegroup_with_given_dhcp_settings(self):
     name = factory.make_name('nodegroup')
     uuid = factory.make_name('uuid')
     dhcp_network, dhcp_settings = make_dhcp_settings()
     ip = factory.getRandomIPInNetwork(dhcp_network)
     nodegroup = NodeGroup.objects.new(name, uuid, ip, **dhcp_settings)
     nodegroup = reload_object(nodegroup)
     interface = get_one(nodegroup.nodegroupinterface_set.all())
     self.assertEqual(name, nodegroup.name)
     self.assertThat(
         interface, MatchesStructure.byEquality(**dhcp_settings))
开发者ID:cloudbase,项目名称:maas,代码行数:11,代码来源:test_nodegroup.py


示例19: test_add_duplicate_work_item

    def test_add_duplicate_work_item(self):
        spec, work_items = self._dup_work_items_set_up()

        # Test that we can insert another duplicate work item.
        new_wi3_data = work_items[0].copy()
        new_wi3_data['sequence'] = 4
        work_items.append(new_wi3_data)
        spec.updateWorkItems(work_items)

        self.assertEqual(5, len(spec.work_items))
        for data, obj in zip(work_items, list(spec.work_items)):
            self.assertThat(obj, MatchesStructure.byEquality(**data))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:12,代码来源:test_specification.py


示例20: test_arg_setup

 def test_arg_setup(self):
     parser = self.get_parser()
     filename = factory.getRandomString()
     args = parser.parse_args((
         '--no-overwrite',
         '--filename', filename,
         '--mode', "111"))
     self.assertThat(
         args, MatchesStructure.byEquality(
             no_overwrite=True,
             filename=filename,
             mode="111"))
开发者ID:deepakhajare,项目名称:maas,代码行数:12,代码来源:test_utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testutil.get_data_file_name函数代码示例发布时间:2022-05-27
下一篇:
Python matchers.raises函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap