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

Python mommy.make_recipe函数代码示例

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

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



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

示例1: test_create_block_redirects_if_no_blocktypes_available

    def test_create_block_redirects_if_no_blocktypes_available(self):
        """
        Test that create block form redirects if trying to create a
        block with an event type that the user already has
        """
        event_type = mommy.make_recipe('booking.event_type_PC')
        block_type_pc5 = mommy.make_recipe(
            'booking.blocktype5', event_type=event_type
        )
        block_type_pc10 = mommy.make_recipe(
            'booking.blocktype5', event_type=event_type
        )
        mommy.make_recipe(
            'booking.block', user=self.user, block_type=block_type_pc5,
            paid=True
        )
        # create form with a different blocktype, but one with the same event
        # type as the user's booked block
        form_data = {'block_type': block_type_pc10}

        url = reverse('booking:add_block')
        request = self.factory.post(url, form_data)
        self._set_session(self.user, request)

        form_data = {'block_type': block_type_pc10.id}
        form = BlockCreateForm(data=form_data)
        form.full_clean()
        view = setup_view(BlockCreateView, request)
        resp = view.form_valid(view, form)

        self.assertEqual(resp.status_code, 302)
开发者ID:judy2k,项目名称:pipsevents,代码行数:31,代码来源:test_block_views.py


示例2: test_image_operations_as_authorised_users

    def test_image_operations_as_authorised_users(self):
        # create a campaign & deployment that ONLY bill can see
        bills_campaign = mommy.make_one("catamidb.Campaign", id=3, short_name="cp__1")
        bills_deployment = mommy.make_recipe("catamidb.Deployment3", id=3, campaign=bills_campaign)
        bills_image = mommy.make_recipe("catamidb.Image3", id=3, deployment=bills_deployment)
        assign("view_campaign", self.user_bill, bills_campaign)

        # check that bill can see via the API
        response = self.bill_api_client.get(self.image_url, format="json")
        self.assertValidJSONResponse(response)
        self.assertEqual(len(self.deserialize(response)["objects"]), 3)

        # check that bill can get to the object itself
        response = self.bill_api_client.get(self.image_url + "3/", format="json")
        self.assertValidJSONResponse(response)

        # check that bob can not see - now we know tastypie API has correct
        # permission validation
        response = self.bob_api_client.get(self.image_url, format="json")
        self.assertValidJSONResponse(response)
        self.assertEqual(len(self.deserialize(response)["objects"]), 2)

        # check bob can NOT get to the hidden object
        response = self.bob_api_client.get(self.image_url + "3/", format="json")
        self.assertHttpUnauthorized(response)

        # check that anonymous can see public ones as well
        response = self.anon_api_client.get(self.image_url, format="json")
        self.assertValidJSONResponse(response)
        self.assertEqual(len(self.deserialize(response)["objects"]), 2)

        # check anonymous can NOT get to the hidden object
        response = self.anon_api_client.get(self.image_url + "3/", format="json")
        self.assertHttpUnauthorized(response)
开发者ID:stevenvandervalk,项目名称:benthobox,代码行数:34,代码来源:tests.py


示例3: test_not_assignments_where_not_student

 def test_not_assignments_where_not_student(self):
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     mommy.make_recipe('devilry.apps.core.assignment_activeperiod_start')
     mockresponse = self.mock_http200_getrequest_htmls(requestuser=testuser)
     self.assertEqual(
             0,
             self.__get_assignment_count(selector=mockresponse.selector))
开发者ID:Nasmi1,项目名称:devilry-django,代码行数:7,代码来源:test_dashboard.py


示例4: testContent

 def testContent(self):
     mommy.make_recipe('apps.front.user')
     mommy.make_recipe('apps.lecturers.lecturer')
     login(self)
     response = self.client.get('/dozenten/')
     self.assertContains(response, '<h1>Unsere Dozenten</h1>')
     self.assertContains(response, 'David<br />Krakaduku')
开发者ID:AwaisKazi,项目名称:web,代码行数:7,代码来源:test_views.py


示例5: test_grouplist_status_waiting_for_feedback_sanity

 def test_grouplist_status_waiting_for_feedback_sanity(self):
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     testperiod = mommy.make_recipe('devilry.apps.core.period_active')
     testgroup = mommy.make('core.AssignmentGroup',
                            parentnode=mommy.make_recipe('devilry.apps.core.assignment_activeperiod_start',
                                                         parentnode=testperiod))
     mommy.make('core.Candidate',
                relatedstudent__user=testuser,
                assignment_group=testgroup)
     devilry_group_mommy_factories.feedbackset_first_attempt_published(
             group=testgroup, grading_points=3)
     devilry_group_mommy_factories.feedbackset_new_attempt_unpublished(
             group=testgroup,
             deadline_datetime=timezone.now() - timedelta(days=2))
     mockresponse = self.mock_http200_getrequest_htmls(
             requestuser=testuser, cradmin_role=testperiod)
     self.assertFalse(
             mockresponse.selector.exists(
                     '.devilry-cradmin-groupitemvalue '
                     '.devilry-cradmin-groupitemvalue-grade'))
     self.assertEqual(
             'Status: waiting for feedback',
             mockresponse.selector.one(
                     '.devilry-cradmin-groupitemvalue '
                     '.devilry-cradmin-groupitemvalue-status').alltext_normalized)
开发者ID:devilry,项目名称:devilry-django,代码行数:25,代码来源:test_overview.py


示例6: test_status_choice_filter

    def test_status_choice_filter(self):
        open_bookings = mommy.make_recipe(
            'booking.booking', event=self.event, status='OPEN', _quantity=5
            )
        cancelled_bookings = mommy.make_recipe(
            'booking.booking',
            event=self.event,
            status='CANCELLED',
            _quantity=5
            )
        resp = self._get_response(
            self.staff_user, self.event.slug, status_choice='ALL'
        )
        # bookings: open - 5 plus 2 created in setup, cancelled = 5 (12)
        # also shows forms for available spaces (16 max, 9 spaces)
        self.assertEquals(len(resp.context_data['formset'].forms), 21)

        resp = self._get_response(
            self.staff_user, self.event.slug, status_choice='OPEN'
        )
        # 5 open plus 2 created in setup, plus empty forms for available
        # spaces to max participants 16
        forms = resp.context_data['formset'].forms
        self.assertEquals(len(forms), 16)
        self.assertEquals(
            set([form.instance.status for form in forms]), {'OPEN'}
            )

        resp = self._get_response(
            self.staff_user, self.event.slug, status_choice='CANCELLED'
        )
        forms = resp.context_data['formset'].forms
        # 5 cancelled plus empty forms for 9 available spaces
        self.assertEquals(len(forms), 14)
开发者ID:judy2k,项目名称:pipsevents,代码行数:34,代码来源:test_register_views.py


示例7: test_events_excluded_from_form_for_instructors

    def test_events_excluded_from_form_for_instructors(
            self, mock_tz, mock_date
    ):
        mock_tz.now.return_value = datetime(
            year=2015, month=9, day=7, hour=10, tzinfo=timezone.utc
        )
        mock_date.today.return_value = date(year=2015, month=9, day=7)
        mommy.make_recipe(
            'booking.future_EV',
            date=datetime(
                year=2015, month=9, day=7,
                hour=18, minute=0, tzinfo=timezone.utc
            ),
            _quantity=3
        )
        pole_classes = mommy.make_recipe(
            'booking.future_PC',
            date=datetime(
                year=2015, month=9, day=7,
                hour=18, minute=0, tzinfo=timezone.utc
            ),
            _quantity=3
        )
        resp = self._get_response(self.instructor_user)

        form = resp.context_data['form']
        self.assertEqual(len(form.events), 3)
        self.assertEqual(
            sorted([ev.id for ev in form.events]),
            sorted([ev.id for ev in pole_classes])
        )
开发者ID:judy2k,项目名称:pipsevents,代码行数:31,代码来源:test_register_views.py


示例8: test_create_existing_booking_txn_with_txn_id

 def test_create_existing_booking_txn_with_txn_id(self):
     """
     if the existing transaction is already associated with a paypal
     transaction_id, we do need to create a new transaction, with new
     invoice number with incremented counter
     """
     user = mommy.make_recipe('flex_bookings.user', username="testuser")
     booking = mommy.make_recipe(
         'flex_bookings.booking', user=user, event__name='test event'
     )
     booking_txn = helpers.create_booking_paypal_transaction(user, booking)
     self.assertEqual(booking_txn.booking, booking)
     self.assertEqual(
         booking_txn.invoice_id,
         'testuser-te-{}-inv#001'.format(
             booking.event.date.strftime("%d%m%y%H%M")
         )
     )
     self.assertEqual(PaypalBookingTransaction.objects.count(), 1)
     booking_txn.transaction_id = "123"
     booking_txn.save()
     new_booking_txn = helpers.create_booking_paypal_transaction(user, booking)
     self.assertEqual(PaypalBookingTransaction.objects.count(), 2)
     self.assertEqual(
         new_booking_txn.invoice_id,
         'testuser-te-{}-inv#002'.format(
             booking.event.date.strftime("%d%m%y%H%M")
         )
     )
开发者ID:rebkwok,项目名称:flexibeast,代码行数:29,代码来源:tests.py


示例9: test_create_booking_with_duplicate_invoice_number

    def test_create_booking_with_duplicate_invoice_number(self):
        user = mommy.make_recipe('flex_bookings.user', username="testuser")
        booking = mommy.make_recipe(
            'flex_bookings.booking', user=user, event__name='test event',
            event__date=datetime(2015, 2, 1, 10, 0, tzinfo=timezone.utc)
        )
        booking1 = mommy.make_recipe(
            'flex_bookings.booking', user=user, event__name='test event1',
            event__date=datetime(2015, 2, 1, 10, 0, tzinfo=timezone.utc)
        )
        booking_txn = helpers.create_booking_paypal_transaction(user, booking)
        self.assertEqual(booking_txn.booking, booking)
        self.assertEqual(
            booking_txn.invoice_id,
            'testuser-te-{}-inv#001'.format(
                booking.event.date.strftime("%d%m%y%H%M")
            )
        )

        booking1_txn = helpers.create_booking_paypal_transaction(user, booking1)
        self.assertEqual(booking1_txn.booking, booking1)
        self.assertNotEqual(
            booking1_txn.invoice_id,
            'testuser-te-{}-inv#001'.format(
                booking1.event.date.strftime("%d%m%y%H%M")
            )
        )
        # to avoid duplication, the counter is set to 6 digits, the first 3
        # random between 100 and 999
        self.assertEqual(len(booking1_txn.invoice_id.split('#')[-1]), 6)
开发者ID:rebkwok,项目名称:flexibeast,代码行数:30,代码来源:tests.py


示例10: test_paypal_booking_admin_display

    def test_paypal_booking_admin_display(self):
        user = mommy.make_recipe(
            'flex_bookings.user', first_name='Test', last_name='User')
        booking = mommy.make_recipe('flex_bookings.booking', user=user)
        pptrans = helpers.create_booking_paypal_transaction(
            booking.user, booking
        )

        ppbooking_admin = PaypalBookingTransactionAdmin(
            PaypalBookingTransaction, AdminSite()
        )
        ppbooking_query = ppbooking_admin.get_queryset(None)[0]

        self.assertEqual(
            ppbooking_admin.get_booking_id(ppbooking_query), booking.id
        )
        self.assertEqual(
            ppbooking_admin.get_user(ppbooking_query), 'Test User'
        )
        self.assertEqual(
            ppbooking_admin.get_event(ppbooking_query), booking.event
        )
        self.assertEqual(
            ppbooking_admin.cost(ppbooking_query),
            u"\u00A3{}.00".format(booking.event.cost)
        )
开发者ID:rebkwok,项目名称:flexibeast,代码行数:26,代码来源:tests.py


示例11: test_paypal_block_admin_display

    def test_paypal_block_admin_display(self):
        user = mommy.make_recipe(
            'flex_bookings.user', first_name='Test', last_name='User'
        )
        events = mommy.make_recipe('flex_bookings.future_EV', _quantity=5)
        block = mommy.make_recipe('flex_bookings.block')
        for event in events:
            block.events.add(event)
            booking = mommy.make_recipe(
                'flex_bookings.booking', user=user, event=event
            )
            block.bookings.add(booking)
        pptrans = helpers.create_block_paypal_transaction(
            user, block
        )

        ppblock_admin = PaypalBlockTransactionAdmin(
            PaypalBlockTransaction, AdminSite()
        )
        ppblock_query = ppblock_admin.get_queryset(None)[0]

        self.assertEqual(
            ppblock_admin.get_block_id(ppblock_query), block.id
        )
        self.assertEqual(
            ppblock_admin.get_user(ppblock_query), 'Test User'
        )
        self.assertEqual(
            ppblock_admin.cost(ppblock_query),
            u"\u00A3{:.2f}".format(
                block.item_cost * block.bookings.count()
            )
        )
开发者ID:rebkwok,项目名称:flexibeast,代码行数:33,代码来源:tests.py


示例12: test_categories_with_published_articles

    def test_categories_with_published_articles(self):
        c1 = mommy.make_recipe('kb.tests.category_with_articles')
        c2 = mommy.make_recipe('kb.tests.category_without_articles')
        mommy.make_recipe('kb.tests.draft_article', category=c2)

        self.assertSeqEqual(Category.objects.all(), [c1, c2])
        self.assertSeqEqual(Category.objects.categories(), [c1])
开发者ID:eliostvs,项目名称:django-kb,代码行数:7,代码来源:tests_models.py


示例13: test_upcoming_assignments_header

 def test_upcoming_assignments_header(self):
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     mommy.make_recipe('devilry.apps.core.assignment_activeperiod_start')
     mockresponse = self.mock_http200_getrequest_htmls(requestuser=testuser)
     self.assertEqual(
         mockresponse.selector.one('.devilry-student-dashboard-upcoming-assignments-header').alltext_normalized,
         'Upcoming assignments')
开发者ID:devilry,项目名称:devilry-django,代码行数:7,代码来源:test_dashboard.py


示例14: test_cannot_post_delete_block_page_if_block_has_bookings

    def test_cannot_post_delete_block_page_if_block_has_bookings(self):
        mommy.make_recipe('booking.booking', block=self.block)
        resp = self._post_response(self.user, self.block.id)
        self.assertEqual(resp.status_code, 302)
        self.assertIn(resp.url, reverse('booking:permission_denied'))

        self.assertEqual(Block.objects.first(), self.block)
开发者ID:judy2k,项目名称:pipsevents,代码行数:7,代码来源:test_block_views.py


示例15: test_block_format_block_available_not_used

    def test_block_format_block_available_not_used(self):
        # paid (user has available block not used)
        event = mommy.make_recipe(
            'booking.future_EV', max_participants=1, event_type__subtype='Event'
        )
        # block used
        block_type = mommy.make(
            BlockType, event_type=event.event_type, size=3
        )
        block = mommy.make_recipe(
            'booking.block', block_type=block_type, user=self.user, paid=True
        )
        mommy.make_recipe(
            'booking.booking',  event=event, user=self.user, paid=True,
            payment_confirmed=True
        )
        resp = self._get_response(self.staff_user, event.slug)

        # block is hidden as booking is paid
        self.assertIn(
            '<span class="hide"><select class="form-control input-xs '
            'studioadmin-list" id="id_bookings-0-block" '
            'name="bookings-0-block">',
            resp.rendered_content
        )
        # block info is displayed
        self.assertIn(
            'Active block not used', resp.rendered_content
        )
开发者ID:judy2k,项目名称:pipsevents,代码行数:29,代码来源:test_register_views.py


示例16: test_create_existing_block_transaction_with_txn_id

    def test_create_existing_block_transaction_with_txn_id(self):
        user = mommy.make_recipe('flex_bookings.user', username="testuser")
        events = mommy.make_recipe('flex_bookings.future_EV', _quantity=5)
        block = mommy.make_recipe(
            'flex_bookings.block', name="test block"
        )
        for event in events:
            block.events.add(event)
        block_txn = helpers.create_block_paypal_transaction(user, block)
        block_txn.transaction_id = "test transaction id"
        block_txn.save()
        self.assertEqual(block_txn.block, block)
        self.assertEqual(
            block_txn.invoice_id,
            'testuser-tb-inv#001'
        )
        self.assertEqual(PaypalBlockTransaction.objects.count(), 1)

        second_block_txn = helpers.create_block_paypal_transaction(user, block)
        self.assertEqual(PaypalBlockTransaction.objects.count(), 2)
        self.assertNotEqual(block_txn, second_block_txn)
        self.assertEqual(
            second_block_txn.invoice_id,
            'testuser-tb-inv#002'
        )
开发者ID:rebkwok,项目名称:flexibeast,代码行数:25,代码来源:tests.py


示例17: test_block_format_paid_no_block_available

    def test_block_format_paid_no_block_available(self):
        # paid (user has available block not used)
        event = mommy.make_recipe('booking.future_EV', max_participants=1)
        # block used
        block_type = mommy.make(
            BlockType, event_type=event.event_type, size=3
        )
        # paid (user has no available block)
        user1 = mommy.make_recipe('booking.user')
        mommy.make_recipe(
            'booking.booking',  event=event, user=user1, paid=True,
            payment_confirmed=True
        )

        resp = self._get_response(self.staff_user, event.slug)

        # block is hidden as booking is paid
        self.assertIn(
            '<span class="hide"><select class="hide" id="id_bookings-0-block" '
            'name="bookings-0-block">',
            resp.rendered_content
        )
        # block info is displayed
        self.assertIn(
            'No active block', resp.rendered_content
        )
开发者ID:judy2k,项目名称:pipsevents,代码行数:26,代码来源:test_register_views.py


示例18: test_create_block_transaction_with_duplicate_invoice_number

    def test_create_block_transaction_with_duplicate_invoice_number(self):
        user = mommy.make_recipe('flex_bookings.user', username="testuser")
        events = mommy.make_recipe('flex_bookings.future_EV', _quantity=5)
        block = mommy.make_recipe(
            'flex_bookings.block', name="test block"
        )
        for event in events:
            block.events.add(event)

        events1 = mommy.make_recipe('flex_bookings.future_EV', _quantity=5)
        block1 = mommy.make_recipe(
            'flex_bookings.block', name="test block"
        )
        for event in events1:
            block1.events.add(event)

        block_txn = helpers.create_block_paypal_transaction(user, block)
        self.assertEqual(block_txn.block, block)
        self.assertEqual(
            block_txn.invoice_id,
            'testuser-tb-inv#001'
        )
        self.assertEqual(PaypalBlockTransaction.objects.count(), 1)

        second_block_txn = helpers.create_block_paypal_transaction(user, block1)
        self.assertEqual(PaypalBlockTransaction.objects.count(), 2)
        self.assertNotEqual(block_txn, second_block_txn)
        # to avoid duplication, the counter is set to 6 digits, the first 3
        # random between 100 and 999
        self.assertEqual(len(second_block_txn.invoice_id.split('#')[-1]), 6)
开发者ID:rebkwok,项目名称:flexibeast,代码行数:30,代码来源:tests.py


示例19: test_submitting_form_for_classes_redirects_to_class_register

    def test_submitting_form_for_classes_redirects_to_class_register(self):
        event = mommy.make_recipe('booking.future_PC')
        bookings = mommy.make_recipe(
            'booking.booking', event=event, status='OPEN', _quantity=2
        )

        form_data = self.formset_data({
            'bookings-0-id': bookings[0].id,
            'bookings-0-user': bookings[0].user.id,
            'bookings-0-paid': bookings[0].paid,
            'bookings-0-attended': bookings[0].attended,
            'bookings-1-id': bookings[1].id,
            'bookings-1-user': bookings[1].user.id,
            'bookings-1-paid': bookings[1].paid,
            'bookings-1-attended': bookings[1].attended,
        })

        resp = self._post_response(
            self.staff_user, event.slug,
            form_data=form_data,
            print_view=False,
            ev_type='class',
            status_choice='OPEN'
        )
        self.assertEquals(resp.status_code, 302)
        self.assertEquals(
            resp.url,
            reverse(
                'studioadmin:class_register',
            args=[event.slug, 'OPEN']
            )
        )
开发者ID:judy2k,项目名称:pipsevents,代码行数:32,代码来源:test_register_views.py


示例20: test_paypal_notify_url_with_block

    def test_paypal_notify_url_with_block(self, mock_postback):
        mock_postback.return_value = b"VERIFIED"
        user = mommy.make_recipe('flex_bookings.user')
        events = mommy.make_recipe('flex_bookings.future_EV', _quantity=5)
        block = mommy.make_recipe('flex_bookings.block')
        for event in events:
            block.events.add(event)
            booking = mommy.make_recipe(
                'flex_bookings.booking', user=user, event=event
            )
            block.bookings.add(booking)
        invoice_id = helpers.create_block_paypal_transaction(
            user, block
        ).invoice_id

        self.assertFalse(PayPalIPN.objects.exists())
        params = dict(IPN_POST_PARAMS)
        params.update(
            {
                'custom': b('block {}'.format(block.id)),
                'invoice': b(invoice_id)
            }
        )
        resp = self.paypal_post(params)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(PayPalIPN.objects.count(), 1)
        ppipn = PayPalIPN.objects.first()
        self.assertFalse(ppipn.flag)
        self.assertEqual(ppipn.flag_info, '')

        block.refresh_from_db()
        # 2 emails sent, to user and studio
        self.assertEqual(len(mail.outbox), 2)
开发者ID:rebkwok,项目名称:flexibeast,代码行数:33,代码来源:tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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