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


Python fake.sentence函数代码示例

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


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

示例1: setUp

    def setUp(self):
        super(RegistrationEmbargoViewsTestCase, self).setUp()
        self.user = AuthUserFactory()
        self.project = ProjectFactory(creator=self.user)
        self.draft = DraftRegistrationFactory(branched_from=self.project)
        self.registration = RegistrationFactory(project=self.project, creator=self.user)

        current_month = timezone.now().strftime('%B')
        current_year = timezone.now().strftime('%Y')

        self.valid_make_public_payload = json.dumps({
            u'embargoEndDate': u'Fri, 01, {month} {year} 00:00:00 GMT'.format(
                month=current_month,
                year=current_year
            ),
            u'registrationChoice': 'immediate',
            u'summary': unicode(fake.sentence())
        })
        valid_date = timezone.now() + datetime.timedelta(days=180)
        self.valid_embargo_payload = json.dumps({
            u'embargoEndDate': unicode(valid_date.strftime('%a, %d, %B %Y %H:%M:%S')) + u' GMT',
            u'registrationChoice': 'embargo',
            u'summary': unicode(fake.sentence())
        })
        self.invalid_embargo_date_payload = json.dumps({
            u'embargoEndDate': u"Thu, 01 {month} {year} 05:00:00 GMT".format(
                month=current_month,
                year=str(int(current_year) - 1)
            ),
            u'registrationChoice': 'embargo',
            u'summary': unicode(fake.sentence())
        })
开发者ID:leb2dg,项目名称:osf.io,代码行数:32,代码来源:test_embargoes.py

示例2: test_current_version_number_with_non_contiguous_version_numbers

 def test_current_version_number_with_non_contiguous_version_numbers(self):
     wiki = WikiFactory()
     for i in range(1, 9):
         WikiVersion(wiki_page=wiki, identifier=i, content=fake.sentence()).save()
     for i in range(2, 6):
         WikiVersion(wiki_page=wiki, identifier=i, content=fake.sentence()).save()
     assert wiki.current_version_number == 5
     latest_version = wiki.versions.order_by('-created')[0]
     assert latest_version.is_current
     assert wiki.get_version(5) == latest_version
开发者ID:icereval,项目名称:osf.io,代码行数:10,代码来源:test_models.py

示例3: setUp

    def setUp(self):
        super(RegistrationRetractionModelsTestCase, self).setUp()

        self.user = UserFactory()
        self.registration = RegistrationFactory(creator=self.user, is_public=True)
        self.valid_justification = fake.sentence()
        self.invalid_justification = fake.text(max_nb_chars=3000)
开发者ID:icereval,项目名称:osf.io,代码行数:7,代码来源:test_retractions.py

示例4: test_invalid_rejection_token_raises_InvalidSanctionRejectionToken

 def test_invalid_rejection_token_raises_InvalidSanctionRejectionToken(self):
     self.registration.embargo_registration(self.user, datetime.datetime.utcnow() + datetime.timedelta(days=10))
     self.registration.save()
     assert_true(self.registration.is_pending_embargo)
     with assert_raises(InvalidSanctionRejectionToken):
         self.registration.embargo.disapprove_embargo(self.user, fake.sentence())
     assert_true(self.registration.is_pending_embargo)
开发者ID:caseyrygt,项目名称:osf.io,代码行数:7,代码来源:test_registration_embargoes.py

示例5: test_GET_approve_registration_without_embargo_raises_HTTPBad_Request

 def test_GET_approve_registration_without_embargo_raises_HTTPBad_Request(self):
     assert_false(self.registration.pending_embargo)
     res = self.app.get(
         self.registration.web_url_for('node_registration_embargo_approve', token=fake.sentence()),
         auth=self.user.auth,
         expect_errors=True
     )
     assert_equal(res.status_code, 400)
开发者ID:XTech2K,项目名称:osf.io,代码行数:8,代码来源:test_registration_embargoes.py

示例6: test_GET_from_unauthorized_user_raises_HTTPForbidden

 def test_GET_from_unauthorized_user_raises_HTTPForbidden(self):
     unauthorized_user = AuthUserFactory()
     res = self.app.get(
         self.registration.web_url_for('node_registration_embargo_approve', token=fake.sentence()),
         auth=unauthorized_user.auth,
         expect_errors=True
     )
     assert_equal(res.status_code, 403)
开发者ID:XTech2K,项目名称:osf.io,代码行数:8,代码来源:test_registration_embargoes.py

示例7: test_prereg

 def test_prereg(self):
     meta = {
         'q1': {
             'value': fake.sentence()
         }
     }
     
     node = factories.NodeFactory(creator=self.osf_user)
     prereg_pending = []
     for i in range(3):
         draft = factories.DraftRegistrationFactory(
             branched_from=node, 
             registration_schema=self.prereg_schema,
             registration_metadata=meta
         )
         draft.submit_for_review(
             self.osf_user, {
                 'registration_choice': 'immediate'
             },
             save=True
         )
         prereg_pending.append(draft)
     non_prereg_pending = []
     for i in range(3):            
         draft = factories.DraftRegistrationFactory(
             branched_from=node, 
             registration_schema=self.other_schema
         )
         draft.submit_for_review(
             self.osf_user, {
                 'registration_choice': 'immediate'
             },
             save=True
         )
         non_prereg_pending.append(draft)
     prereg_not_pending = []
     for i in range(3):
         draft = factories.DraftRegistrationFactory(
             branched_from=node, 
             registration_schema=self.prereg_schema
         )
         prereg_not_pending.append(draft)
     non_prereg_not_pending = []
     for i in range(3):            
         draft = factories.DraftRegistrationFactory(
             branched_from=node, 
             registration_schema=self.other_schema
         )
         non_prereg_not_pending.append(draft)
     
     url = reverse('pre_reg:prereg')        
     res = self.client.get(url)
     
     assert_equal(res.status_code, http.OK)
     assert_in('drafts', res.context)
     assert_equal(len(res.context['drafts']), len(prereg_pending))
     for draft in res.context['drafts']:
         assert_in(draft['pk'], [d._id for d in prereg_pending])
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:58,代码来源:test_views.py

示例8: setUp

    def setUp(self):
        super(RegistrationRetractionModelsTestCase, self).setUp()
        self.mock_registration_update = mock.patch('website.project.tasks.on_registration_updated')
        self.mock_registration_update.start()

        self.user = UserFactory()
        self.registration = RegistrationFactory(creator=self.user, is_public=True)
        self.valid_justification = fake.sentence()
        self.invalid_justification = fake.text(max_nb_chars=3000)
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:test_retractions.py

示例9: test_invalid_approval_token_raises_InvalidRetractionApprovalToken

    def test_invalid_approval_token_raises_InvalidRetractionApprovalToken(self):
        self.registration.retract_registration(self.user)
        self.registration.save()
        assert_true(self.registration.pending_retraction)

        with assert_raises(InvalidRetractionApprovalToken):
            self.registration.retraction.approve_retraction(self.user, fake.sentence())
        assert_true(self.registration.pending_retraction)
        assert_false(self.registration.is_retracted)
开发者ID:XTech2K,项目名称:osf.io,代码行数:9,代码来源:test_registration_retractions.py

示例10: setUp

    def setUp(self):
        super(RegistrationRetractionViewsTestCase, self).setUp()
        self.user = AuthUserFactory()
        self.registered_from = ProjectFactory(creator=self.user, is_public=True)
        self.registration = RegistrationFactory(project=self.registered_from, is_public=True)

        self.retraction_post_url = self.registration.api_url_for('node_registration_retraction_post')
        self.retraction_get_url = self.registration.web_url_for('node_registration_retraction_get')
        self.justification = fake.sentence()
开发者ID:baylee-d,项目名称:osf.io,代码行数:9,代码来源:test_retractions.py

示例11: test_invalid_rejection_token_raises_InvalidSanctionRejectionToken

 def test_invalid_rejection_token_raises_InvalidSanctionRejectionToken(self):
     self.registration.require_approval(
         self.user
     )
     self.registration.save()
     assert_true(self.registration.is_pending_registration)
     with assert_raises(InvalidSanctionRejectionToken):
         self.registration.registration_approval.reject(self.user, fake.sentence())
     assert_true(self.registration.is_pending_registration)
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:9,代码来源:test_registration_approvals.py

示例12: test_invalid_rejection_token_raises_InvalidSanctionRejectionToken

    def test_invalid_rejection_token_raises_InvalidSanctionRejectionToken(self):
        self.registration.retract_registration(self.user)
        self.registration.save()
        assert_true(self.registration.is_pending_retraction)

        with assert_raises(InvalidSanctionRejectionToken):
            self.registration.retraction.disapprove_retraction(self.user, fake.sentence())
        assert_true(self.registration.is_pending_retraction)
        assert_false(self.registration.is_retracted)
开发者ID:baylee-d,项目名称:osf.io,代码行数:9,代码来源:test_retractions.py

示例13: test_invalid_disapproval_token_raises_InvalidEmbargoDisapprovalToken

 def test_invalid_disapproval_token_raises_InvalidEmbargoDisapprovalToken(self):
     self.registration.embargo_registration(
         self.user,
         datetime.datetime.utcnow() + datetime.timedelta(days=10)
     )
     self.registration.save()
     assert_true(self.registration.pending_embargo)
     with assert_raises(InvalidEmbargoDisapprovalToken):
         self.registration.embargo.disapprove_embargo(self.user, fake.sentence())
     assert_true(self.registration.pending_embargo)
     assert_false(self.registration.embargo_end_date)
开发者ID:XTech2K,项目名称:osf.io,代码行数:11,代码来源:test_registration_embargoes.py

示例14: render_generations_from_parent

def render_generations_from_parent(parent, creator, num_generations):
    current_gen = parent
    for generation in xrange(0, num_generations):
        next_gen = NodeFactory(
            parent=current_gen,
            creator=creator,
            title=fake.sentence(),
            description=fake.paragraph()
        )
        current_gen = next_gen
    return current_gen
开发者ID:545zhou,项目名称:osf.io,代码行数:11,代码来源:factories.py

示例15: test_GET_approve_with_invalid_token_returns_HTTPBad_Request

    def test_GET_approve_with_invalid_token_returns_HTTPBad_Request(self):
        self.registration.embargo_registration(
            self.user,
            datetime.datetime.utcnow() + datetime.timedelta(days=10)
        )
        self.registration.save()
        assert_true(self.registration.pending_embargo)

        res = self.app.get(
            self.registration.web_url_for('node_registration_embargo_approve', token=fake.sentence()),
            auth=self.user.auth,
            expect_errors=True
        )
        assert_equal(res.status_code, 400)
开发者ID:XTech2K,项目名称:osf.io,代码行数:14,代码来源:test_registration_embargoes.py


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