本文整理汇总了Python中wagtail.images.tests.utils.get_test_image_file函数的典型用法代码示例。如果您正苦于以下问题:Python get_test_image_file函数的具体用法?Python get_test_image_file怎么用?Python get_test_image_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_test_image_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_compare_imagechooserblock
def test_compare_imagechooserblock(self):
image_model = get_image_model()
test_image_1 = image_model.objects.create(
title="Test image 1",
file=get_test_image_file(),
)
test_image_2 = image_model.objects.create(
title="Test image 2",
file=get_test_image_file(),
)
field = StreamPage._meta.get_field('body')
comparison = self.comparison_class(
field,
StreamPage(body=StreamValue(field.stream_block, [
('image', test_image_1, '1'),
])),
StreamPage(body=StreamValue(field.stream_block, [
('image', test_image_2, '1'),
])),
)
result = comparison.htmldiff()
self.assertIn('<div class="preview-image deletion">', result)
self.assertIn('alt="Test image 1"', result)
self.assertIn('<div class="preview-image addition">', result)
self.assertIn('alt="Test image 2"', result)
self.assertIsInstance(result, SafeText)
self.assertTrue(comparison.has_changed())
开发者ID:nealtodd,项目名称:wagtail,代码行数:31,代码来源:test_compare.py
示例2: test_footer_importable
def test_footer_importable(self):
content = constants.ARTICLE_PAGE_RESPONSE
content_copy = dict(content)
# Validate Assumptions
# The images have already been imported
# The record keeper has mapped the relationship
foreign_image_id = content["image"]["id"]
image = Image.objects.create(
title=content["image"]["title"],
file=get_test_image_file(),
)
foreign_social_media_image_id = content["social_media_image"]["id"]
social_media_image = Image.objects.create(
title=content["social_media_image"]["title"],
file=get_test_image_file(),
)
record_keeper = importers.RecordKeeper()
record_keeper.record_image_relation(foreign_image_id, image.id)
record_keeper.record_image_relation(
foreign_social_media_image_id, social_media_image.id)
class_ = FooterPage
page = FooterPage.create_page(
content_copy, class_, record_keeper=record_keeper)
self.check_article_and_footer_fields(page, content, record_keeper)
开发者ID:praekelt,项目名称:molo,代码行数:31,代码来源:test_model_mixins.py
示例3: setUp
def setUp(self):
self.mk_main()
self.main = Main.objects.all().first()
self.factory = RequestFactory()
self.language_setting = Languages.objects.create(
site_id=self.main.get_site().pk)
self.english = SiteLanguageRelation.objects.create(
language_setting=self.language_setting,
locale='en',
is_active=True)
# LanguageRelation.objects.create(
# page=main, language=self.english)
self.french = SiteLanguageRelation.objects.create(
language_setting=self.language_setting,
locale='fr',
is_active=True)
# LanguageRelation.objects.create(
# page=self, language=self.french)
# Create an image for running tests on
self.image = Image.objects.create(
title="Test image",
file=get_test_image_file(),
)
self.yourmind = self.mk_section(
self.section_index, title='Your mind')
self.yourmind_sub = self.mk_section(
self.yourmind, title='Your mind subsection')
self.mk_main2()
self.main2 = Main.objects.all().last()
self.language_setting2 = Languages.objects.create(
site_id=self.main2.get_site().pk)
self.english2 = SiteLanguageRelation.objects.create(
language_setting=self.language_setting2,
locale='en',
is_active=True)
self.spanish = SiteLanguageRelation.objects.create(
language_setting=self.language_setting2,
locale='es',
is_active=True)
# Create an image for running tests on
self.image = Image.objects.create(
title="Test image",
file=get_test_image_file(),
)
self.image2 = Image.objects.create(
title="Test image 2",
file=get_test_image_file(),
)
self.yourmind2 = self.mk_section(
self.section_index2, title='Your mind')
self.yourmind_sub2 = self.mk_section(
self.yourmind2, title='Your mind subsection')
开发者ID:praekelt,项目名称:molo,代码行数:58,代码来源:test_models.py
示例4: setUpTestData
def setUpTestData(cls):
image_model = get_image_model()
cls.test_image_1 = image_model.objects.create(
title="Test image 1",
file=get_test_image_file(),
)
cls.test_image_2 = image_model.objects.create(
title="Test image 2",
file=get_test_image_file(),
)
开发者ID:BertrandBordage,项目名称:wagtail,代码行数:10,代码来源:test_compare.py
示例5: test_banner_importable
def test_banner_importable(self):
content = constants.BANNER_PAGE_RESPONSE
content_copy = dict(content)
# Validate Assumptions
# The images have already been imported
# The record keeper has mapped the relationship
foreign_image_id = content["banner"]["id"]
image = Image.objects.create(
title=content["banner"]["title"],
file=get_test_image_file(),
)
record_keeper = importers.RecordKeeper()
record_keeper.record_image_relation(foreign_image_id, image.id)
class_ = BannerPage
page = BannerPage.create_page(
content_copy, class_, record_keeper=record_keeper)
self.assertEqual(page.title, content["title"])
self.assertEqual(page.external_link, content["external_link"])
# check that banner link has been created
self.assertEqual(
(record_keeper.foreign_to_foreign_map["banner_link_page"]
[content["id"]]),
content["banner_link_page"]["id"])
# check that banner image has been attached
self.assertTrue(page.banner)
self.assertEqual(page.banner, image)
self.assertEqual(page.banner.title, content["banner"]["title"])
开发者ID:praekelt,项目名称:molo,代码行数:35,代码来源:test_model_mixins.py
示例6: test_invalid
def test_invalid(self):
fil = Filter(spec='width-400|format-foo')
image = Image.objects.create(
title="Test image",
file=get_test_image_file(),
)
self.assertRaises(InvalidFilterSpecError, fil.run, image, BytesIO())
开发者ID:morris-tech,项目名称:wagtail,代码行数:7,代码来源:test_image_operations.py
示例7: test_lazy_load_queryset_bulk
def test_lazy_load_queryset_bulk(self):
"""
Ensure that lazy loading StreamField works when gotten as part of a
queryset list
"""
file_obj = get_test_image_file()
image_1 = Image.objects.create(title='Test image 1', file=file_obj)
image_3 = Image.objects.create(title='Test image 3', file=file_obj)
with_image = StreamModel.objects.create(body=json.dumps([
{'type': 'image', 'value': image_1.pk},
{'type': 'image', 'value': None},
{'type': 'image', 'value': image_3.pk},
{'type': 'text', 'value': 'foo'}]))
with self.assertNumQueries(1):
instance = StreamModel.objects.get(pk=with_image.pk)
# Prefetch all image blocks
with self.assertNumQueries(1):
instance.body[0]
# 1. Further image block access should not execute any db lookups
# 2. The blank block '1' should be None.
# 3. The values should be in the original order.
with self.assertNumQueries(0):
assert instance.body[0].value.title == 'Test image 1'
assert instance.body[1].value is None
assert instance.body[2].value.title == 'Test image 3'
开发者ID:morris-tech,项目名称:wagtail,代码行数:29,代码来源:test_streamfield.py
示例8: test_image_file_deleted_oncommit
def test_image_file_deleted_oncommit(self):
with transaction.atomic():
image = get_image_model().objects.create(title="Test Image", file=get_test_image_file())
self.assertTrue(image.file.storage.exists(image.file.name))
image.delete()
self.assertTrue(image.file.storage.exists(image.file.name))
self.assertFalse(image.file.storage.exists(image.file.name))
开发者ID:Henk-JanVanHasselaar,项目名称:wagtail,代码行数:7,代码来源:test_signal_handlers.py
示例9: test_uploaded_avatar
def test_uploaded_avatar(self):
user_profile = UserProfile.get_for_user(self.test_user)
user_profile.avatar = get_test_image_file(filename='custom-avatar.png')
user_profile.save()
url = avatar_url(self.test_user)
self.assertIn('custom-avatar', url)
开发者ID:BertrandBordage,项目名称:wagtail,代码行数:7,代码来源:test_templatetags.py
示例10: test_invalid_length
def test_invalid_length(self):
fil = Filter(spec='width-400|bgcolor-1234')
image = Image.objects.create(
title="Test image",
file=get_test_image_file(),
)
self.assertRaises(ValueError, fil.run, image, BytesIO())
开发者ID:ThibWeb,项目名称:wagtail,代码行数:7,代码来源:test_image_operations.py
示例11: test_rendition_file_deleted_oncommit
def test_rendition_file_deleted_oncommit(self):
with transaction.atomic():
image = get_image_model().objects.create(title="Test Image", file=get_test_image_file())
rendition = image.get_rendition('original')
self.assertTrue(rendition.file.storage.exists(rendition.file.name))
rendition.delete()
self.assertTrue(rendition.file.storage.exists(rendition.file.name))
self.assertFalse(rendition.file.storage.exists(rendition.file.name))
开发者ID:Henk-JanVanHasselaar,项目名称:wagtail,代码行数:8,代码来源:test_signal_handlers.py
示例12: test_6_digit_hex
def test_6_digit_hex(self):
fil = Filter(spec='width-400|bgcolor-ffffff')
image = Image.objects.create(
title="Test image",
file=get_test_image_file(),
)
out = fil.run(image, BytesIO())
self.assertFalse(out.has_alpha())
开发者ID:Henk-JanVanHasselaar,项目名称:wagtail,代码行数:9,代码来源:test_image_operations.py
示例13: test_get_replica_image_returns_none
def test_get_replica_image_returns_none(self):
Image.objects.create(
title='local image',
file=get_test_image_file(),
)
self.importer.get_image_details()
replica_image = self.importer.get_replica_image('wrong_hash')
self.assertTrue(replica_image is None)
开发者ID:praekelt,项目名称:molo,代码行数:9,代码来源:test_importers.py
示例14: test_gif
def test_gif(self):
fil = Filter(spec='width-400|format-gif')
image = Image.objects.create(
title="Test image",
file=get_test_image_file(),
)
out = fil.run(image, BytesIO())
self.assertEqual(out.format_name, 'gif')
开发者ID:morris-tech,项目名称:wagtail,代码行数:9,代码来源:test_image_operations.py
示例15: test_original_has_alpha
def test_original_has_alpha(self):
# Checks that the test image we're using has alpha
fil = Filter(spec='width-400')
image = Image.objects.create(
title="Test image",
file=get_test_image_file(),
)
out = fil.run(image, BytesIO())
self.assertTrue(out.has_alpha())
开发者ID:Henk-JanVanHasselaar,项目名称:wagtail,代码行数:10,代码来源:test_image_operations.py
示例16: setUp
def setUp(self):
self.image = Image.objects.create(
title='Test image',
file=get_test_image_file())
self.with_image = StreamModel.objects.create(body=json.dumps([
{'type': 'image', 'value': self.image.pk},
{'type': 'text', 'value': 'foo'}]))
self.no_image = StreamModel.objects.create(body=json.dumps([
{'type': 'text', 'value': 'foo'}]))
self.nonjson_body = StreamModel.objects.create(body="<h1>hello world</h1>")
开发者ID:morris-tech,项目名称:wagtail,代码行数:10,代码来源:test_streamfield.py
示例17: mocked_fetch_and_create_image
def mocked_fetch_and_create_image(url, image_title):
image = Image.objects.create(
title=image_title,
file=get_test_image_file(),
)
context = {
"file_url": url,
"foreign_title": image_title,
}
return (image, context)
开发者ID:praekelt,项目名称:molo,代码行数:10,代码来源:utils.py
示例18: setUp
def setUp(self):
self.login()
img = Image.objects.create(
title="LOTR cover",
file=get_test_image_file(),
)
book = Book.objects.get(title="The Lord of the Rings")
book.cover_image = img
book.save()
开发者ID:zerolab,项目名称:wagtail,代码行数:10,代码来源:test_simple_modeladmin.py
示例19: test_get_replica_image_returns_match
def test_get_replica_image_returns_match(self):
local_image = Image.objects.create(
title='local image',
file=get_test_image_file(),
)
local_image_hash = get_image_hash(local_image)
self.assertEqual(Image.objects.count(), 1)
self.importer.get_image_details()
replica_image = self.importer.get_replica_image(local_image_hash)
self.assertEqual(replica_image, local_image)
开发者ID:praekelt,项目名称:molo,代码行数:11,代码来源:test_importers.py
示例20: test_attaching_image_info_save_image_twice
def test_attaching_image_info_save_image_twice(self):
# creates the image which includes saving the image
image = Image.objects.create(
title="Test image",
file=get_test_image_file(),
)
self.assertEqual(ImageInfo.objects.count(), 1)
image.save()
# confirm that we're not creating an ImageInfo
# object each time
self.assertEqual(ImageInfo.objects.count(), 1)
开发者ID:praekelt,项目名称:molo,代码行数:11,代码来源:test_images.py
注:本文中的wagtail.images.tests.utils.get_test_image_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论