def test_download_private_no_permission(self):
#Create contact for the user
profile = create_profile_contact(self.user)
contact = profile.contact
#Create category
cat = ArticleCategory.objects.create(name="CAT")
#create a public doc
file_ = File(self._get_file())
doc = mommy.make(Document, is_private=True, file=file_, category=cat)
#check the url
private_url = reverse('coop_cms_download_doc', args=[doc.id])
self.assertEqual(doc.get_download_url(), private_url)
#login and download
response = self.client.get(doc.get_download_url(), follow=True)
self.assertEqual(response.status_code, 200)
#self.assertEquals(response['Content-Disposition'], "attachment; filename=unittest1.txt")
self.assertEquals(response['Content-Type'], "text/plain")
评论列表
文章目录