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

Python base.Mockup类代码示例

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

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



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

示例1: test_constraints

 def test_constraints(self):
     filler = Mockup(BasicModel)
     for obj in filler.create(100):
         self.assertTrue(len(obj.chars) > 0)
         self.assertEqual(type(obj.chars), unicode)
         self.assertTrue(len(obj.shortchars) <= 2)
         self.assertEqual(type(obj.shortchars), unicode)
         self.assertTrue(type(obj.blankchars), unicode)
         self.assertEqualOr(type(obj.nullchars), unicode, None)
         self.assertEqual(type(obj.slugfield), unicode)
         self.assertEqual(type(obj.defaultint), int)
         self.assertEqual(obj.defaultint, 1)
         self.assertEqual(type(obj.intfield), int)
         self.assertEqual(type(obj.sintfield), int)
         self.assertEqual(type(obj.pintfield), int)
         self.assertEqual(type(obj.psintfield), int)
         self.assertEqual(type(obj.datefield), date)
         self.assertEqual(type(obj.datetimefield), datetime)
         self.assertEqual(type(obj.defaultdatetime), datetime)
         self.assertEqual(obj.defaultdatetime, y2k())
         self.assertEqual(type(obj.decimalfield), Decimal)
         self.assertTrue("@" in obj.emailfield)
         self.assertTrue("." in obj.emailfield)
         self.assertTrue(" " not in obj.emailfield)
         self.assertTrue(obj.ipaddressfield.count("."), 3)
         self.assertTrue(len(obj.ipaddressfield) >= 7)
     self.assertEqual(BasicModel.objects.count(), 100)
开发者ID:manjescc,项目名称:Mejorandola,代码行数:27,代码来源:tests.py


示例2: test_follow_m2m

    def test_follow_m2m(self):
        related = Mockup(SimpleModel).create()[0]
        self.assertEqual(SimpleModel.objects.count(), 1)

        filler = Mockup(M2MModel, follow_m2m=(2, 10))
        for obj in filler.create(10):
            self.assertEqual(list(obj.m2m.all()), [related])
开发者ID:manjescc,项目名称:Mejorandola,代码行数:7,代码来源:tests.py


示例3: test_generate_m2m_with_intermediary_model

 def test_generate_m2m_with_intermediary_model(self):
     filler = Mockup(M2MModelThrough, generate_m2m=(1, 5))
     all_m2m = set()
     for obj in filler.create(10):
         self.assertTrue(1 <= obj.m2m.count() <= 5)
         all_m2m.update(obj.m2m.all())
     self.assertEqual(SimpleModel.objects.count(), len(all_m2m))
开发者ID:manjescc,项目名称:Mejorandola,代码行数:7,代码来源:tests.py


示例4: test_deep_generate_foreignkeys

 def test_deep_generate_foreignkeys(self):
     filler = Mockup(
         DeepLinkModel2,
         generate_fk=True)
     for obj in filler.create(10):
         self.assertEqual(obj.related.__class__, DeepLinkModel1)
         self.assertEqual(obj.related.related.__class__, SimpleModel)
         self.assertEqual(obj.related.related2.__class__, SimpleModel)
开发者ID:airtonix,项目名称:django-mockups,代码行数:8,代码来源:tests.py


示例5: test_generate_foreignkeys

 def test_generate_foreignkeys(self):
     for m in RELATED_MODELS:
         filler = Mockup(
             m,
             generate_fk=True)
         for obj in filler.create(100):
             self.assertEqual(obj.related.__class__, BasicModel)
             self.assertEqual(obj.limitedfk.name, 'foo')
开发者ID:airtonix,项目名称:django-mockups,代码行数:8,代码来源:tests.py


示例6: test_unique_together

 def test_unique_together(self):
     filler = Mockup(UniqueTogetherTestModel)
     count1 = len(filler.model._meta.
         get_field_by_name('choice1')[0].choices)
     count2 = len(filler.model._meta.
         get_field_by_name('choice2')[0].choices)
     for obj in filler.create(count1 * count2):
         pass
开发者ID:airtonix,项目名称:django-mockups,代码行数:8,代码来源:tests.py


示例7: test_generate_only_some_foreignkeys

 def test_generate_only_some_foreignkeys(self):
     for m in RELATED_MODELS:
         filler = Mockup(
             m,
             generate_fk=('related',))
         for obj in filler.create(100):
             self.assertEqual(obj.related.__class__, BasicModel)
             self.assertEqual(obj.limitedfk, None)
开发者ID:airtonix,项目名称:django-mockups,代码行数:8,代码来源:tests.py


示例8: test_generate_fk_for_o2o

    def test_generate_fk_for_o2o(self):
        # OneToOneField is the same as a ForeignKey with unique=True
        filler = Mockup(O2OModel, generate_fk=True)

        all_o2o = set()
        for obj in filler.create(10):
            all_o2o.add(obj.o2o)

        self.assertEqual(set(SimpleModel.objects.all()), all_o2o)
开发者ID:manjescc,项目名称:Mejorandola,代码行数:9,代码来源:tests.py


示例9: test_follow_fk_for_o2o

    def test_follow_fk_for_o2o(self):
        # OneToOneField is the same as a ForeignKey with unique=True
        filler = Mockup(O2OModel, follow_fk=True)

        simple = SimpleModel.objects.create()
        obj = filler.create()[0]
        self.assertEqual(obj.o2o, simple)

        self.assertRaises(CreateInstanceError, filler.create)
开发者ID:manjescc,项目名称:Mejorandola,代码行数:9,代码来源:tests.py


示例10: test_deep_generate_foreignkeys2

 def test_deep_generate_foreignkeys2(self):
     filler = Mockup(
         DeepLinkModel2,
         follow_fk=False,
         generate_fk=('related', 'related__related'))
     for obj in filler.create(10):
         self.assertEqual(obj.related.__class__, DeepLinkModel1)
         self.assertEqual(obj.related.related.__class__, SimpleModel)
         self.assertEqual(obj.related.related2, None)
开发者ID:airtonix,项目名称:django-mockups,代码行数:9,代码来源:tests.py


示例11: test_follow_only_some_m2m

    def test_follow_only_some_m2m(self):
        related = Mockup(SimpleModel).create()[0]
        self.assertEqual(SimpleModel.objects.count(), 1)
        other_related = Mockup(OtherSimpleModel).create()[0]
        self.assertEqual(OtherSimpleModel.objects.count(), 1)

        filler = Mockup(M2MModel, follow_m2m={"m2m": (2, 10)})
        for obj in filler.create(10):
            self.assertEqual(list(obj.m2m.all()), [related])
            self.assertEqual(list(obj.secondm2m.all()), [])
开发者ID:manjescc,项目名称:Mejorandola,代码行数:10,代码来源:tests.py


示例12: test_generate_only_some_m2m

 def test_generate_only_some_m2m(self):
     filler = Mockup(M2MModel, generate_m2m={"m2m": (1, 5)})
     all_m2m = set()
     all_secondm2m = set()
     for obj in filler.create(10):
         self.assertTrue(1 <= obj.m2m.count() <= 5)
         self.assertEqual(0, obj.secondm2m.count())
         all_m2m.update(obj.m2m.all())
         all_secondm2m.update(obj.secondm2m.all())
     self.assertEqual(SimpleModel.objects.count(), len(all_m2m))
     self.assertEqual(OtherSimpleModel.objects.count(), len(all_secondm2m))
开发者ID:manjescc,项目名称:Mejorandola,代码行数:11,代码来源:tests.py


示例13: test_follow_only_some_foreignkeys

    def test_follow_only_some_foreignkeys(self):
        related = Mockup(BasicModel).create()[0]
        self.assertEqual(BasicModel.objects.count(), 1)

        simple = SimpleModel.objects.create(name="foo")
        simple2 = SimpleModel.objects.create(name="bar")

        for m in RELATED_MODELS:
            filler = Mockup(m, follow_fk=("related",))
            for obj in filler.create(100):
                self.assertEqual(obj.related, related)
                self.assertEqual(obj.limitedfk, None)
开发者ID:manjescc,项目名称:Mejorandola,代码行数:12,代码来源:tests.py


示例14: test_follow_foreignkeys

    def test_follow_foreignkeys(self):
        related = Mockup(BasicModel).create()[0]
        self.assertEqual(BasicModel.objects.count(), 1)

        simple = SimpleModel.objects.create(name='foo')
        simple2 = SimpleModel.objects.create(name='bar')

        for m in RELATED_MODELS:
            filler = Mockup(
                m,
                follow_fk=True)
            for obj in filler.create(100):
                self.assertEqual(obj.related, related)
                self.assertEqual(obj.limitedfk, simple)
开发者ID:airtonix,项目名称:django-mockups,代码行数:14,代码来源:tests.py


示例15: test_create

 def test_create(self):
     filler = Mockup(BasicModel)
     filler.create(10)
     self.assertEqual(BasicModel.objects.count(), 10)
开发者ID:manjescc,项目名称:Mejorandola,代码行数:4,代码来源:tests.py


示例16: test_unique_field

 def test_unique_field(self):
     filler = Mockup(UniqueTestModel)
     count = len(filler.model._meta.get_field_by_name("choice1")[0].choices)
     for obj in filler.create(count):
         pass
开发者ID:manjescc,项目名称:Mejorandola,代码行数:5,代码来源:tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python log.colored函数代码示例发布时间:2022-05-27
下一篇:
Python common.assertEqual函数代码示例发布时间: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