def test_build_invalid_zip(self):
attachment_name = 'build.json'
attachment_path = os.path.join(settings.MEDIA_ROOT, 'test_attachment')
copyfile(os.path.join(FILES_PATH, 'invalid_archive.zip'),
attachment_path)
attachment = Attachment(
name=attachment_name,
buildable=True
)
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)
with self.assertRaises(SuspiciousOperation):
attachment.build(tracker)
评论列表
文章目录