mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 18:44:23 +00:00
Add two tests for file upload
This commit is contained in:
parent
a02d5a65cb
commit
4542753812
@ -269,3 +269,30 @@ http://git.an
|
||||
# - renaming a page
|
||||
# - changing a page's parent --> check that page's children's full_name
|
||||
# - changing the different groups of the page
|
||||
|
||||
class FileHandlingTest(TestCase):
|
||||
def setUp(self):
|
||||
try:
|
||||
call_command("populate")
|
||||
self.subscriber = User.objects.filter(username="subscriber").first()
|
||||
self.client.login(username='subscriber', password='plop')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def test_create_folder_home(self):
|
||||
response = self.client.post(reverse("core:file_detail", kwargs={"file_id":self.subscriber.home.id}),
|
||||
{"folder_name": "GUY_folder_test"})
|
||||
self.assertTrue(response.status_code == 302)
|
||||
response = self.client.get(reverse("core:file_detail", kwargs={"file_id":self.subscriber.home.id}))
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue("GUY_folder_test</a>" in str(response.content))
|
||||
|
||||
def test_upload_file_home(self):
|
||||
with open("/bin/ls", "rb") as f:
|
||||
response = self.client.post(reverse("core:file_detail", kwargs={"file_id":self.subscriber.home.id}),
|
||||
{"file_field": f})
|
||||
self.assertTrue(response.status_code == 302)
|
||||
response = self.client.get(reverse("core:file_detail", kwargs={"file_id":self.subscriber.home.id}))
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue("ls</a>" in str(response.content))
|
||||
|
||||
|
@ -194,7 +194,7 @@ class FileModerationView(TemplateView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(FileModerationView, self).get_context_data(**kwargs)
|
||||
kwargs['files'] = SithFile.objects.filter(is_moderated=False).all()
|
||||
kwargs['files'] = SithFile.objects.filter(is_moderated=False)[:100]
|
||||
return kwargs
|
||||
|
||||
class FileModerateView(CanEditPropMixin, SingleObjectMixin):
|
||||
|
Loading…
Reference in New Issue
Block a user