def test_build_static(self):
attachment_name = 'b64.png'
attachment_path = os.path.join(settings.MEDIA_ROOT, 'test_attachment')
copyfile(os.path.join(FILES_PATH, 'image.png'), attachment_path)
attachment = Attachment(
name=attachment_name,
buildable=False
)
attachment.file = os.path.join('..', attachment_path)
attachment.save()
kwargs = {
'key': TRACKER_ATTACHMENT_EXECUTED,
'campaign_id': 1,
'target_id': 1,
'value': 'tracker: not opened',
}
tracker = Tracker.objects.create(**kwargs)
res = attachment.build(tracker)
self.assertEqual(res, attachment.file)
# Clean media dir after test
os.remove(attachment_path)
评论列表
文章目录