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


Python milkman.deliver函数代码示例

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


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


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