attachments.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:mercure 作者: synhack 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号