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

Python milkman.deliver函数代码示例

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

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



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

示例1: setUp

    def setUp(self):
        self.page = milkman.deliver(WebPage, slug='test-page', title="page", template='pages/default.html')
        self.page2 = milkman.deliver(WebPage, slug='test-page-2', title="page2", template='pages/default.html')
        self.page_resource = PageResource()
        self.user = User.objects.create_user(username='user', email='[email protected]', password='pass')
        self.client.login(username='user', password='pass')

        self.rf = RequestFactory()
开发者ID:spenoir,项目名称:django-whitelabel,代码行数:8,代码来源:views.py


示例2: test_related_explicit_values

    def test_related_explicit_values(self):
        child = milkman.deliver(Child, root__my_char='foo')
        self.assertEqual(child.root.my_char, 'foo')

        grandchild = milkman.deliver(GrandChild, parent__name='foo', parent__root__my_char='bar')
        self.assertEqual(grandchild.parent.name, 'foo')
        self.assertEqual(grandchild.parent.root.my_char, 'bar')

        root = milkman.deliver(Root)
        grandchild = milkman.deliver(GrandChild, parent__root=root)
        self.assertEqual(root.pk, grandchild.parent.root.pk)
开发者ID:EDITD,项目名称:milkman,代码行数:11,代码来源:tests.py


示例3: test_has_correct_objects

    def test_has_correct_objects(self):
        "has correct objects for user (those which can be modified)"
        yes = milkman.deliver(Trip, where="Yesland", user=self.user)
        no = milkman.deliver(Trip, where="Nopeland", user=self.user)

        yes.fully_authorize(self.user)

        resp = self.client.get(reverse("trips:list"))

        self.assertIn(yes, resp.context["trip_list"])
        self.assertNotIn(no, resp.context["trip_list"])
开发者ID:BrianHicks,项目名称:funding,代码行数:11,代码来源:views_tests.py


示例4: check_assigns_permissions

def check_assigns_permissions(perm):
    user = milkman.deliver(User)
    ba = milkman.deliver(BalancedAccount)
    ba.fully_authorize(user)

    perm = 'funding.%s_balancedaccount' % perm
    try:
        assert user.has_perm(perm, ba), \
            'user has no perm %s' % perm
    finally:
        user.delete()
        ba.delete()
开发者ID:BrianHicks,项目名称:funding,代码行数:12,代码来源:models_tests.py


示例5: test_force_random

    def test_force_random(self):
        root1 = milkman.deliver('tests.root')
        self.assertFalse(root1.my_string)

        root2 = milkman.deliver('tests.root', my_string=milkman.random)
        self.assertTrue(root2.my_string)

        sibling = milkman.deliver('tests.sibling')
        self.assertFalse(sibling.root)

        sibling = milkman.deliver('tests.sibling', root=milkman.random)
        self.assertTrue(sibling.root in [root1, root2])
开发者ID:pombredanne,项目名称:milkman,代码行数:12,代码来源:tests.py


示例6: check_assigns_permissions

def check_assigns_permissions(perm):
    user = milkman.deliver(User)
    trip = milkman.deliver(Trip)
    trip.fully_authorize(user)

    perm = 'trips.%s_trip' % perm
    try:
        assert user.has_perm(perm, trip), \
            'user has no perm %s' % perm
    finally:
        user.delete()
        trip.delete()
开发者ID:BrianHicks,项目名称:funding,代码行数:12,代码来源:models_tests.py


示例7: check_for_user

def check_for_user(kind, perm):
    user = milkman.deliver(User)
    ba = milkman.deliver(
        BalancedAccount, kind=kind, name=':'.join([kind, perm])
    )
    ba.fully_authorize(user)

    qs = BalancedAccount.objects.for_user(kind, perm, user)
    try:
        assert ba in qs, '%r not in %r' % (ba, qs)
    finally:
        user.delete()
        ba.delete()
开发者ID:BrianHicks,项目名称:funding,代码行数:13,代码来源:models_tests.py


示例8: check_for_user

def check_for_user(perm):
    user = milkman.deliver(User)
    trip = milkman.deliver(
        Trip, name=perm
    )
    trip.fully_authorize(user)

    qs = Trip.objects.for_user(perm, user)
    try:
        assert trip in qs, '%r not in %r' % (trip, qs)
    finally:
        user.delete()
        trip.delete()
开发者ID:BrianHicks,项目名称:funding,代码行数:13,代码来源:models_tests.py


示例9: setUp

 def setUp(self):
     "set up trip"
     super(TripDeleteViewTests, self).setUp()
     self.trip = milkman.deliver(Trip)
     self.addCleanup(self.trip.delete)
     self.url = reverse("trips:delete", kwargs={"pk": self.trip.pk})
     self.trip.fully_authorize(self.user)
开发者ID:BrianHicks,项目名称:funding,代码行数:7,代码来源:views_tests.py


示例10: handle

    def handle(self, *args, **options):
        amount = int(args[0])
        for i in range(amount):
            start_date = random_date(
                datetime.now()+timedelta(days=1),
                datetime.now()+timedelta(days=30))
            end_date = random_date(
                start_date,
                start_date+timedelta(days=30)
            )
            users = []
            for j in range(random.randint(2, 4)):
                user = User.objects.order_by('?')[0]
                if user not in users:
                    users.append(user)
            try:
                country = Country.objects.order_by('?')[0]
            except IndexError:
                country = Country.objects.get_or_create_normalized(
                    name=random.choice(countries))
            trip = milkman.deliver('trip.trip',
                start_date=start_date, end_date=end_date,
                country=country,
                city=random.choice(cities),
                title=u"Поездка_{0}".format(i),
                people=users,
                owner=User.objects.all()[0]
            )
            self.stdout.write("Created trip '{0}'".format(trip))

        self.stdout.write("Successfully created test trips")
开发者ID:divvytravel,项目名称:old_code,代码行数:31,代码来源:create_test_trips.py


示例11: test_required_field

 def test_required_field(self):
     root = milkman.deliver(Root)
     assert isinstance(root.my_auto, int)
     try:
         assert isinstance(
             root.my_biginteger, type(models.BigIntegerField.MAX_BIGINT))
     except AttributeError:
         pass
     assert isinstance(root.my_boolean, bool)
     assert isinstance(root.my_char, str)
     assert isinstance(root.my_commaseperatedinteger, str)
     assert isinstance(root.my_date, str)
     assert isinstance(root.my_datetime, str)
     assert isinstance(root.my_decimal, str)
     assert isinstance(root.my_email, str)
     assert isinstance(root.my_float, float)
     assert isinstance(root.my_integer, int)
     assert isinstance(root.my_ip, str)
     assert (isinstance(root.my_nullboolean, bool)
             or isinstance(root.my_nullboolean, types.NoneType))
     assert isinstance(root.my_positiveinteger, int)
     assert isinstance(root.my_positivesmallinteger, int)
     assert isinstance(root.my_slug, str)
     assert isinstance(root.my_smallinteger, int)
     assert isinstance(root.my_text, str)
     assert isinstance(root.my_time, str)
开发者ID:pombredanne,项目名称:milkman,代码行数:26,代码来源:tests.py


示例12: test_options

    def test_options(self):
        self.assertTrue('OPTIONS' in ArticleResource.allowed_methods)
        uri = self.reverse('author-test-book-article', book=self.book.pk)
        response = self.client.options(uri, data=dict(author=self.author.pk))
        self.assertContains(response, 'OK')

        author = milkman.deliver('main.author')
        response = self.client.options(uri, data=dict(author=author.pk))
        self.assertContains(response, 'OK')
开发者ID:pombredanne,项目名称:adrest,代码行数:9,代码来源:tests.py


示例13: create_page

    def create_page(self, **kwargs):
        letters = list(string.letters)
        random.shuffle(letters)
        random_name = ''.join(letters[:10])

        page_kwargs = {'name' : random_name}
        page_kwargs.update(kwargs)
        
        return milkman.deliver(Page, **page_kwargs)
开发者ID:Wilfred,项目名称:Picky,代码行数:9,代码来源:test_mixins.py


示例14: setUp

    def setUp(self):
        settings.TEST = True

        cache.clear()
   #     johnny_cache.disable()

        self.page = milkman.deliver(WebPage, slug='test-page', title="Test page")
        self.user = User.objects.create_user(username='user',
            email='[email protected]', password='pass')
        self.client.login(username='user', password='pass')
开发者ID:spenoir,项目名称:django-whitelabel,代码行数:10,代码来源:models.py


示例15: test_simply

    def test_simply(self):
        from adrest.utils.serializer import BaseSerializer
        from .models import Task
        user = milkman.deliver('auth.User', username="testusername")
        data = [milkman.deliver(Task, user=user), milkman.deliver(Task, user=user),
                28, 'string']

        serializer = BaseSerializer(_exclude='fake', _include='username', user=dict(
            _fields='email'))
        self.assertEqual(serializer.options['_exclude'], set(['fake']))

        out = serializer.to_simple(data)
        self.assertEqual(out[0]['fields']['username'], data[0].user.username)

        # Test m2o serialization
        serializer = BaseSerializer(_include="task_set", task_set=dict(
            _fields=[]))
        out = serializer.to_simple(user)

        self.assertEquals(len(out['fields']['task_set']), 2)
        for task in out['fields']['task_set']:
            self.assertEquals(task['fields']['user'], user.pk)
            self.assertTrue('title' in task['fields'].keys())
开发者ID:intaxi,项目名称:adrest,代码行数:23,代码来源:tests.py


示例16: test_multiple_sorting

    def test_multiple_sorting(self):

        testuser = milkman.deliver(User)
        testuser.set_password("letmein")
        testuser.save()

        self.create_entries(3, user=testuser)
        self.assertEqual(LogEntry.objects.count(), 6)
        self.assertViewRenders("""
                {% sort objects with "objects" as objects %}
                {% sort others with "others" as others %}
                {{ objects|sorter_tests_pks }}.{{ others|sorter_tests_pks }}
            """, "3.2.1.6.5.4", {"sort_objects": "-id", "sort_others": "-id"},
            objects=LogEntry.objects.exclude(user=testuser),
            others=LogEntry.objects.filter(user=testuser))
开发者ID:adamchainz,项目名称:django-sorter,代码行数:15,代码来源:tests.py


示例17: setUp

    def setUp(self):
        """ Create test tree
        """
        root1 = milkman.deliver(Page)
        page11 = milkman.deliver(Page, parent=root1)
        page12 = milkman.deliver(Page, parent=root1)
        page111 = milkman.deliver(Page, parent=page11)
        page1111 = milkman.deliver(Page, parent=page111)
        page1112 = milkman.deliver(Page, parent=page111)

        self.__dict__.update(locals())
开发者ID:EricSchles,项目名称:simpletree,代码行数:11,代码来源:tests.py


示例18: handle

    def handle(self, *args, **options):
        amount = int(args[0])
        for i in range(amount):
            gender = random.choice((User.GENDERS.male, User.GENDERS.female))
            user = milkman.deliver('users.user',
                email="test_{0}@mail.com".format(i),
                provider="facebook",
                birthday=random_date(
                    datetime.now()-timedelta(days=70*365),
                    datetime.now()-timedelta(days=18*365)
                ),
                gender=gender,
                first_name=str(i),
                last_name="_" + str(gender)
            )
            self.stdout.write("Created user '{0}'".format(user))

        self.stdout.write("Successfully created test users")
开发者ID:divvytravel,项目名称:old_code,代码行数:18,代码来源:create_test_users.py


示例19: setUp

    def setUp(self):
        self.show = milkman.deliver(Show, title="snowprayers")
        self.show.save()
        self.episodes = []
        for i in range(0, 10):
            episode = milkman.deliver(Episode, show=self.show, title="Episode 1")
            episode.save()
            self.episodes.append(episode)
        self.episode = milkman.deliver(Episode, show=self.show, title="Episode")
        self.episode.save()
        long_title = "".join(["x" for i in range(51)])
        self.long_episode1 = milkman.deliver(Episode, show=self.show, title=long_title)
        self.long_episode1.save()

        self.long_episode2 = milkman.deliver(Episode, show=self.show, title=long_title)
        self.long_episode2.save()

        self.enclosure = milkman.deliver(Enclosure, episode=self.episodes[0])
        self.enclosure.save()
开发者ID:a8,项目名称:django-podcasting,代码行数:19,代码来源:tests.py


示例20: test_m2m_related_explicit_values

 def test_m2m_related_explicit_values(self):
     aunt = milkman.deliver(Aunt, uncles__name='foo')
     self.assertEqual(1, len(aunt.uncles.all()))
     self.assertEqual(aunt.uncles.all()[0].name, 'foo')
开发者ID:pombredanne,项目名称:milkman,代码行数:4,代码来源:tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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