本文整理汇总了Python中udata.utils.faker.sentence函数的典型用法代码示例。如果您正苦于以下问题:Python sentence函数的具体用法?Python sentence怎么用?Python sentence使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sentence函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_list_issues_for
def test_list_issues_for(self):
dataset = Dataset.objects.create(title='Test dataset')
issues = []
for i in range(3):
user = UserFactory()
message = Message(content=faker.sentence(), posted_by=user)
issue = Issue.objects.create(
subject=dataset,
user=user,
title='test issue {}'.format(i),
discussion=[message]
)
issues.append(issue)
# Creating a closed issue that shouldn't show up in response.
user = UserFactory()
other_dataset = Dataset.objects.create(title='Other Test dataset')
message = Message(content=faker.sentence(), posted_by=user)
issue = Issue.objects.create(
subject=other_dataset,
user=user,
title='test issue {}'.format(i),
discussion=[message]
)
kwargs = {'for': str(dataset.id)}
response = self.get(url_for('api.issues', **kwargs))
self.assert200(response)
self.assertEqual(len(response.json['data']), len(issues))
开发者ID:odtvince,项目名称:udata,代码行数:29,代码来源:test_issues.py
示例2: test_list_discussions_closed_filter
def test_list_discussions_closed_filter(self):
dataset = Dataset.objects.create(title='Test dataset')
open_discussions = []
closed_discussions = []
for i in range(2):
user = UserFactory()
message = Message(content=faker.sentence(), posted_by=user)
discussion = Discussion.objects.create(
subject=dataset,
user=user,
title='test discussion {}'.format(i),
discussion=[message]
)
open_discussions.append(discussion)
for i in range(3):
user = UserFactory()
message = Message(content=faker.sentence(), posted_by=user)
discussion = Discussion.objects.create(
subject=dataset,
user=user,
title='test discussion {}'.format(i),
discussion=[message],
closed=datetime.now(),
closed_by=user
)
closed_discussions.append(discussion)
response = self.get(url_for('api.discussions', closed=True))
self.assert200(response)
self.assertEqual(len(response.json['data']), len(closed_discussions))
for discussion in response.json['data']:
self.assertIsNotNone(discussion['closed'])
开发者ID:opendatateam,项目名称:udata,代码行数:32,代码来源:test_discussions.py
示例3: test_list_discussions_for
def test_list_discussions_for(self):
dataset = DatasetFactory()
discussions = []
for i in range(3):
user = UserFactory()
message = Message(content=faker.sentence(), posted_by=user)
discussion = Discussion.objects.create(
subject=dataset,
user=user,
title='test discussion {}'.format(i),
discussion=[message]
)
discussions.append(discussion)
user = UserFactory()
message = Message(content=faker.sentence(), posted_by=user)
Discussion.objects.create(
subject=DatasetFactory(),
user=user,
title='test discussion {}'.format(i),
discussion=[message]
)
kwargs = {'for': str(dataset.id)}
response = self.get(url_for('api.discussions', **kwargs))
self.assert200(response)
self.assertEqual(len(response.json['data']), len(discussions))
开发者ID:opendatateam,项目名称:udata,代码行数:27,代码来源:test_discussions.py
示例4: test_closed_issue_mail
def test_closed_issue_mail(self):
owner = UserFactory()
poster = UserFactory()
commenter = UserFactory()
message = Message(content=faker.sentence(), posted_by=poster)
second_message = Message(content=faker.sentence(), posted_by=commenter)
closing_message = Message(content=faker.sentence(), posted_by=owner)
issue = Issue.objects.create(
subject=DatasetFactory(owner=owner),
user=poster,
title=faker.sentence(),
discussion=[message, second_message, closing_message]
)
# issue = IssueFactory()
with capture_mails() as mails:
notify_issue_closed(issue, message=closing_message)
# Should have sent one mail to each participant
# and no mail to the closer
expected_recipients = (poster.email, commenter.email)
self.assertEqual(len(mails), len(expected_recipients))
for mail in mails:
self.assertIn(mail.recipients[0], expected_recipients)
self.assertNotIn(owner.email, mail.recipients)
开发者ID:odtvince,项目名称:udata,代码行数:25,代码来源:test_issues.py
示例5: test_list_issues
def test_list_issues(self):
dataset = Dataset.objects.create(title='Test dataset')
open_issues = []
for i in range(3):
user = UserFactory()
message = Message(content=faker.sentence(), posted_by=user)
issue = Issue.objects.create(
subject=dataset,
user=user,
title='test issue {}'.format(i),
discussion=[message]
)
open_issues.append(issue)
# Creating a closed issue that shouldn't show up in response.
user = UserFactory()
message = Message(content=faker.sentence(), posted_by=user)
closed_issues = [Issue.objects.create(
subject=dataset,
user=user,
title='test issue {}'.format(i),
discussion=[message],
closed=datetime.now(),
closed_by=user
)]
response = self.get(url_for('api.issues'))
self.assert200(response)
expected_length = len(open_issues + closed_issues)
self.assertEqual(len(response.json['data']), expected_length)
开发者ID:odtvince,项目名称:udata,代码行数:29,代码来源:test_issues.py
示例6: test_blogpost_with_first_image_as_thumbnail_as_src_set
def test_blogpost_with_first_image_as_thumbnail_as_src_set(self, blogpost, tpl):
title = faker.sentence()
post_url = faker.uri()
image_url = faker.image_url()
summary = faker.sentence()
tz = pytz.timezone(faker.timezone())
publish_date = faker.date_time(tzinfo=tz)
srcset = ', '.join(
' '.join((faker.image_url(width=w), '{0}w'.format(w)))
for w in ('1200', '1024', '300')
)
sizes = "(max-width: 1200px) 100vw, 1200px"
content = tpl.format(image_url, srcset, sizes)
feed = self.feed('Some blog', title, content, post_url,
published=publish_date,
summary=summary)
post = blogpost(feed)
assert post['title'] == title
assert post['link'] == post_url
assert post['summary'] == summary
assert_equal_dates(post['date'], publish_date)
assert post['image_url'] == image_url
assert post['srcset'] == srcset
assert post['sizes'] == sizes
开发者ID:etalab,项目名称:udata-gouvfr,代码行数:27,代码来源:tests.py
示例7: feed
def feed(self, feed_title, title, content, url, published=None, summary=None,
enclosure=None, media_thumbnail=None):
feed = FeedGenerator()
feed.title(feed_title)
feed.description(faker.sentence())
feed.link({'href': WP_FEED_URL})
entry = feed.add_entry()
entry.title(title)
entry.link({'href': url})
entry.author(name=faker.name())
entry.content(content, type="cdata")
if summary:
entry.description(summary)
if enclosure:
entry.enclosure(url=enclosure['url'],
type=enclosure['type'],
length=str(faker.pyint()))
if media_thumbnail:
feed.load_extension('media')
entry.media.thumbnail({'url': media_thumbnail})
tz = pytz.timezone(faker.timezone())
published = published or faker.date_time(tzinfo=tz)
entry.published(published)
entry.updated(faker.date_time_between(start_date=published, tzinfo=tz))
return feed.rss_str().decode('utf8')
开发者ID:etalab,项目名称:udata-gouvfr,代码行数:27,代码来源:tests.py
示例8: test_prioritize_title_over_alternate_title
def test_prioritize_title_over_alternate_title(self):
title = faker.sentence()
license = LicenseFactory(title=title)
LicenseFactory(alternate_titles=[title])
found = License.guess(title)
assert isinstance(found, License)
assert license.id == found.id
开发者ID:odtvince,项目名称:udata,代码行数:7,代码来源:test_dataset_model.py
示例9: test_update_job_change_type
def test_update_job_change_type(self):
@job('a-job')
def test_job():
pass
task = PeriodicTask.objects.create(
name=faker.name(),
description=faker.sentence(),
task='a-job',
crontab=PeriodicTask.Crontab(minute='5')
)
self.login(AdminFactory())
response = self.put(url_for('api.job', id=task.id), {
'name': task.name,
'description': task.description,
'task': task.task,
'interval': {
'every': 5,
'period': 'minutes',
}
})
self.assert200(response)
self.assertEqual(response.json['id'], str(task.id))
self.assertEqual(response.json['name'], task.name)
self.assertEqual(response.json['task'], task.task)
self.assertEqual(response.json['description'], task.description)
self.assertEqual(response.json['interval']['every'], 5)
self.assertEqual(response.json['interval']['period'], 'minutes')
self.assertIsNone(response.json['crontab'])
开发者ID:odtvince,项目名称:udata,代码行数:31,代码来源:test_workers_api.py
示例10: test_update_job
def test_update_job(self):
@job('a-job')
def test_job():
pass
task = PeriodicTask.objects.create(
name=faker.name(),
description=faker.sentence(),
task='a-job',
crontab=PeriodicTask.Crontab(minute='5')
)
self.login(AdminFactory())
response = self.put(url_for('api.job', id=task.id), {
'name': task.name,
'description': 'New description',
'task': task.task,
'crontab': task.crontab.to_json()
})
self.assert200(response)
self.assertEqual(response.json['id'], str(task.id))
self.assertEqual(response.json['name'], task.name)
self.assertEqual(response.json['task'], task.task)
self.assertEqual(response.json['description'], 'New description')
self.assertIsNotNone(response.json['crontab'])
self.assertIsNone(response.json['interval'])
开发者ID:odtvince,项目名称:udata,代码行数:27,代码来源:test_workers_api.py
示例11: test_request_transfer_to_self
def test_request_transfer_to_self(self):
user = UserFactory()
dataset = VisibleDatasetFactory(owner=user)
comment = faker.sentence()
login_user(user)
with pytest.raises(ValueError):
self.assert_transfer_started(dataset, user, user, comment)
开发者ID:odtvince,项目名称:udata,代码行数:8,代码来源:test_transfer.py
示例12: test_new_issue_mail
def test_new_issue_mail(self):
user = UserFactory()
owner = UserFactory()
message = Message(content=faker.sentence(), posted_by=user)
issue = Issue.objects.create(
subject=DatasetFactory(owner=owner),
user=user,
title=faker.sentence(),
discussion=[message]
)
with capture_mails() as mails:
notify_new_issue(issue)
# Should have sent one mail to the owner
self.assertEqual(len(mails), 1)
self.assertEqual(mails[0].recipients[0], owner.email)
开发者ID:odtvince,项目名称:udata,代码行数:17,代码来源:test_issues.py
示例13: test_request_transfer_user_to_organization
def test_request_transfer_user_to_organization(self):
user = UserFactory()
dataset = VisibleDatasetFactory(owner=user)
recipient = OrganizationFactory()
comment = faker.sentence()
login_user(user)
self.assert_transfer_started(dataset, user, recipient, comment)
开发者ID:odtvince,项目名称:udata,代码行数:8,代码来源:test_transfer.py
示例14: test_request_transfer_not_authorized_not_owner
def test_request_transfer_not_authorized_not_owner(self):
user = UserFactory()
dataset = VisibleDatasetFactory(owner=UserFactory())
recipient = UserFactory()
comment = faker.sentence()
login_user(user)
with pytest.raises(PermissionDenied):
request_transfer(dataset, recipient, comment)
开发者ID:odtvince,项目名称:udata,代码行数:9,代码来源:test_transfer.py
示例15: test_minimal_from_multiple
def test_minimal_from_multiple(self):
node = BNode()
g = Graph()
title = faker.sentence()
g.add((node, RDF.type, DCAT.Dataset))
g.add((node, DCT.title, Literal(title)))
for i in range(3):
other = BNode()
g.add((other, RDF.type, DCAT.Dataset))
g.add((other, DCT.title, Literal(faker.sentence())))
dataset = dataset_from_rdf(g, node=node)
dataset.validate()
assert isinstance(dataset, Dataset)
assert dataset.title == title
开发者ID:opendatateam,项目名称:udata,代码行数:18,代码来源:test_dataset_rdf.py
示例16: test_request_transfer_organization_to_user
def test_request_transfer_organization_to_user(self):
user = UserFactory()
member = Member(user=user, role='admin')
org = OrganizationFactory(members=[member])
dataset = VisibleDatasetFactory(owner=user, organization=org)
recipient = UserFactory()
comment = faker.sentence()
login_user(user)
self.assert_transfer_started(dataset, org, recipient, comment)
开发者ID:odtvince,项目名称:udata,代码行数:10,代码来源:test_transfer.py
示例17: test_basic_blogpost
def test_basic_blogpost(self, blogpost):
title = faker.sentence()
post_url = faker.uri()
tz = pytz.timezone(faker.timezone())
publish_date = faker.date_time(tzinfo=tz)
content = faker.sentence()
html_content = '<div>{0}</div>'.format(content)
feed = self.feed('Some blog', title, html_content, post_url,
published=publish_date)
post = blogpost(feed)
assert post['title'] == title
assert post['link'] == post_url
assert post['summary'] == content
assert_equal_dates(post['date'], publish_date)
assert 'image_url' not in post
assert 'srcset' not in post
assert 'sizes' not in post
开发者ID:etalab,项目名称:udata-gouvfr,代码行数:19,代码来源:tests.py
示例18: test_issues_for_user_with_org
def test_issues_for_user_with_org(self):
user = UserFactory()
member = Member(user=user, role='editor')
org = OrganizationFactory(members=[member])
dataset = DatasetFactory(organization=org)
reuse = ReuseFactory(organization=org)
open_issues = []
for i in range(3):
sender = UserFactory()
message = Message(content=faker.sentence(), posted_by=sender)
open_issues.append(Issue.objects.create(
subject=dataset,
user=sender,
title=faker.sentence(),
discussion=[message]
))
open_issues.append(Issue.objects.create(
subject=reuse,
user=sender,
title=faker.sentence(),
discussion=[message]
))
# Creating a closed issue that shouldn't show up in response.
other_user = UserFactory()
message = Message(content=faker.sentence(), posted_by=other_user)
Issue.objects.create(
subject=dataset,
user=other_user,
title=faker.sentence(),
discussion=[message],
closed=datetime.now(),
closed_by=user
)
issues = issues_for(user)
self.assertIsInstance(issues, db.BaseQuerySet)
self.assertEqual(len(issues), len(open_issues))
for issue in issues:
self.assertIn(issue, open_issues)
开发者ID:odtvince,项目名称:udata,代码行数:42,代码来源:test_issues.py
示例19: test_blogpost_with_first_image_as_thumbnail
def test_blogpost_with_first_image_as_thumbnail(self, blogpost):
title = faker.sentence()
post_url = faker.uri()
image_url = faker.image_url()
summary = faker.sentence()
tz = pytz.timezone(faker.timezone())
publish_date = faker.date_time(tzinfo=tz)
content = '<p><img class="whatever" src="{0}" /> {1}</p>'.format(image_url, summary)
feed = self.feed('Some blog', title, content, post_url,
published=publish_date)
post = blogpost(feed)
assert post['title'] == title
assert post['link'] == post_url
assert post['summary'] == summary
assert_equal_dates(post['date'], publish_date)
assert post['image_url'] == image_url
assert 'srcset' not in post
assert 'sizes' not in post
开发者ID:etalab,项目名称:udata-gouvfr,代码行数:20,代码来源:tests.py
示例20: test_request_transfer_not_authorized_not_admin
def test_request_transfer_not_authorized_not_admin(self):
user = UserFactory()
member = Member(user=user, role='editor')
org = OrganizationFactory(members=[member])
dataset = VisibleDatasetFactory(organization=org)
recipient = UserFactory()
comment = faker.sentence()
login_user(user)
with pytest.raises(PermissionDenied):
request_transfer(dataset, recipient, comment)
开发者ID:odtvince,项目名称:udata,代码行数:11,代码来源:test_transfer.py
注:本文中的udata.utils.faker.sentence函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论