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


Python mommy.make方法代码示例

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


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

示例1: test_forward_call

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def test_forward_call(self):
        # Arrange
        lead_source = mommy.make(
            LeadSource,
            incoming_number='+15555555555',
            forwarding_number='+16666666666')

        # Act
        response = self.client.post(
            '/call-tracking/forward-call',
            {'Called': '+15555555555', 'Caller': '+17777777777', 'CallerCity': 'Washington', 'CallerState': 'DC'})

        # Assert
        self.assertEqual(response.status_code, 200)
        self.assertIn('<Dial>+16666666666</Dial>', str(response.content))

        # Check that a new lead was created
        lead = Lead.objects.get(source=lead_source)
        self.assertEqual(lead.city, 'Washington')
        self.assertEqual(lead.state, 'DC') 
开发者ID:TwilioDevEd,项目名称:call-tracking-django,代码行数:22,代码来源:test_views.py

示例2: test_changelist_view_post_from_user_with_vd_perm_on_model1

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def test_changelist_view_post_from_user_with_vd_perm_on_model1(self):
        obj = mommy.make('test_app.TestModel1')
        data = {
            'index': ['0'],
            'action': ['delete_selected'],
            'select_across': ['0'],
            '_selected_action': [str(obj.pk)]
        }
        self.client.login(
            username='user_with_vd_perm_on_model1',
            password='simple_user',
        )
        response = self.client.post(
            reverse('admin:%s_%s_changelist' % ('test_app', 'testmodel1')),
            data=data,
        )

        assert response.status_code == 200
        assert response.context['title'] == 'Are you sure?' 
开发者ID:ctxis,项目名称:django-admin-view-permission,代码行数:21,代码来源:test_views.py

示例3: fake_analysis

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def fake_analysis(**kwargs):
    if isinstance(kwargs.get('input_file'), (six.string_types, six.binary_type)):
        kwargs['input_file'] = fake_related_file(file=kwargs['input_file'])

    if isinstance(kwargs.get('lookup_errors_file'), (six.string_types, six.binary_type)):
        kwargs['lookup_errors_file'] = fake_related_file(file=kwargs['lookup_errors_file'])

    if isinstance(kwargs.get('lookup_success_file'), (six.string_types, six.binary_type)):
        kwargs['lookup_success_file'] = fake_related_file(file=kwargs['lookup_success_file'])

    if isinstance(kwargs.get('lookup_validation_file'), (six.string_types, six.binary_type)):
        kwargs['lookup_validation_file'] = fake_related_file(file=kwargs['lookup_validation_file'])

    if isinstance(kwargs.get('output_file'), (six.string_types, six.binary_type)):
        kwargs['output_file'] = fake_related_file(file=kwargs['output_file'])

    if isinstance(kwargs.get('settings_file'), (six.string_types, six.binary_type)):
        kwargs['settings_file'] = fake_related_file(file=kwargs['settings_file'])

    return mommy.make(Analysis, **kwargs) 
开发者ID:OasisLMF,项目名称:OasisPlatform,代码行数:22,代码来源:fakes.py

示例4: setUp

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def setUp(self):
        self.sura = mommy.make('quran_text.sura', name='Al-Bakarah', index=2)
        self.ayah = mommy.make('quran_text.ayah', number=1, sura=self.sura,
                               text='بسم الله الرحمن الرحيم')
        self.ayah_2 = mommy.make('quran_text.ayah', number=2, sura=self.sura,
                                 text='الحمد لله رب العالمين')
        self.tafseer = mommy.make('quran_tafseer.Tafseer', name='simple',
                                  language='ar', book_name='simple book',
                                  author='random')
        self.tafseer_text = mommy.make('quran_tafseer.TafseerText',
                                       ayah=self.ayah, tafseer=self.tafseer,
                                       text='بسم الله الرحمن الرحيم')
        self.tafseer_text_2 = mommy.make('quran_tafseer.TafseerText',
                                         ayah=self.ayah_2,
                                         tafseer=self.tafseer,
                                         text='الحمد لله رب العالمين') 
开发者ID:Quran-Tafseer,项目名称:tafseer_api,代码行数:18,代码来源:test_views.py

示例5: setUp

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def setUp(self):
        """
        Set up the following market of Bids for a single bug:
            url: http://github.com/codesy/codesy/issues/37
            user1: ask 50,  offer 0
            user2: ask 100, offer 10
            user3: ask 0,   offer 30
        """
        self.url = 'http://github.com/codesy/codesy/issues/37'
        self.issue = mommy.make(Issue, url=self.url)
        self.user1 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user1@test.com')
        self.user2 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user2@test.com')
        self.user3 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user3@test.com')
        self.bid1 = mommy.make(Bid, user=self.user1,
                               ask=50, offer=0, url=self.url)
        self.bid2 = mommy.make(Bid, user=self.user2,
                               ask=100, offer=10, url=self.url)
        self.bid3 = mommy.make(Bid, user=self.user3,
                               ask=0, offer=30, url=self.url) 
开发者ID:codesy,项目名称:codesy,代码行数:24,代码来源:__init__.py

示例6: test_save_updates_datetimes

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def test_save_updates_datetimes(self):
        test_bid = mommy.make(Bid)
        test_bid = Bid.objects.get(pk=test_bid.pk)
        test_bid_created = test_bid.created
        self.assertTrue(
            timezone.now() >= test_bid_created.replace(),
            "Bid.created should be auto-populated."
        )
        time.sleep(1)
        test_bid.ask = 100
        test_bid.offer = 10
        test_bid.save()
        self.assertEqual(test_bid_created, test_bid.created,
                         "Bid.created should stay the same after an update.")
        test_bid_modified = test_bid.modified
        self.assertTrue(test_bid_modified >= test_bid_created,
                        "Bid.modified should be auto-populated on update.")
        self.assertTrue(
            timezone.now() >= test_bid_modified.replace(),
            "Bid.modified should be auto-populated."
        ) 
开发者ID:codesy,项目名称:codesy,代码行数:23,代码来源:model_tests.py

示例7: test_send_mail_to_matching_askers

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def test_send_mail_to_matching_askers(self, mock_send_mail):
        user = mommy.make(settings.AUTH_USER_MODEL)
        bid1_subject = "[codesy] There's $50 waiting for you!"
        bid2_subject = "[codesy] There's $100 waiting for you!"
        mock_send_mail.expects_call().with_args(
            bid1_subject,
            arg.any(),
            arg.any(),
            ['user1@test.com']
        )
        mock_send_mail.next_call().with_args(
            bid2_subject,
            arg.any(),
            arg.any(),
            ['user2@test.com']
        )

        offer_bid = mommy.make(
            Bid, offer=100, user=user, ask=1000, url=self.url
        )
        offer_bid.save() 
开发者ID:codesy,项目名称:codesy,代码行数:23,代码来源:model_tests.py

示例8: test_only_send_mail_to_unsent_matching_askers

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def test_only_send_mail_to_unsent_matching_askers(self, mock_send_mail):
        user = mommy.make(settings.AUTH_USER_MODEL)
        self.bid1.ask_match_sent = timezone.now()
        self.bid1.save()
        subject = "[codesy] There's $100 waiting for you!"

        mock_send_mail.expects_call().with_args(
            subject,
            arg.any(),
            arg.any(),
            ['user2@test.com']
        )

        offer_bid = mommy.make(
            Bid, offer=100, user=user, ask=1000, url=self.url
        )
        offer_bid.save() 
开发者ID:codesy,项目名称:codesy,代码行数:19,代码来源:model_tests.py

示例9: setUp

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def setUp(self):
        """
        Add a final bid and a user2 claim to the MarketWithBidsTestCase,
        so the final market for the bug is now:
            url: http://github.com/codesy/codesy/issues/37
            user1: ask 50,  offer 0  (ask is met)
            user2: ask 100, offer 10
            user3: ask 0,   offer 30
            user4: ask 200, offer 10
        And user1 is making the claim
        """
        super(NotifyMatchingOfferersTest, self).setUp()
        self.user4 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user4@test.com')
        self.bid4 = mommy.make(Bid, user=self.user4,
                               ask=200, offer=10, url=self.url)
        self.evidence = ('https://github.com/codesy/codesy/commit/'
                         '4f1bcd014ec735918bebd1c386e2f99a7f83ff64') 
开发者ID:codesy,项目名称:codesy,代码行数:20,代码来源:model_tests.py

示例10: test_index_list_active_jobs

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def test_index_list_active_jobs(self):
        mommy.make(Job, status=0)
        response = self.client.get(reverse("job-home"))
        self.assertEquals(len(response.context["jobs"]), 1) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:6,代码来源:test_views.py

示例11: test_show_inactive_job_returns_404

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def test_show_inactive_job_returns_404(self):
        job = mommy.make(Job, status=0)
        response = self.client.get(reverse("job-show", args=[job.pk]))
        self.assertEquals(response.status_code, 404) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:6,代码来源:test_views.py

示例12: test_external_link_not_required

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def test_external_link_not_required(self):
        mommy.make(Job, external_link="")
        self.assertEquals(len(Job.objects.all()), 1) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:5,代码来源:test_models.py

示例13: test_token_is_unique

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def test_token_is_unique(self):
        firstjob = mommy.make(Job, token='12345')
        secondjob = mommy.make(Job, token='12345')

        self.assertNotEqual(firstjob.token, secondjob.token) 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:7,代码来源:test_models.py

示例14: test_home_page_extra_context

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def test_home_page_extra_context(self):
        # Arrange
        lead_source = mommy.make(LeadSource, incoming_number='+15555555555')

        # Act
        response = self.client.get('/')

        # Assert
        self.assertEqual(response.status_code, 200)
        self.assertIn('415', str(response.content))
        self.assertEqual(response.context['lead_sources'][0], lead_source) 
开发者ID:TwilioDevEd,项目名称:call-tracking-django,代码行数:13,代码来源:test_views.py

示例15: test_str_name

# 需要导入模块: from model_mommy import mommy [as 别名]
# 或者: from model_mommy.mommy import make [as 别名]
def test_str_name(self):
        # Arrange
        lead_source = mommy.make(
            LeadSource,
            name='Downtown billboard',
            incoming_number='+15555555555')

        # Assert
        self.assertEqual(str(lead_source), 'Downtown billboard - +15555555555') 
开发者ID:TwilioDevEd,项目名称:call-tracking-django,代码行数:11,代码来源:test_models.py


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