Beispiel #1
0
	def test_local_file_download(self):
		"""
		Tests local file download.
		"""
		download = SimpleUrlDownload.create("http://localhost")
		download.save()
		download.start()
		self.assertEqual(download.file_size, download.downloaded_file_size)
		self.assertEqual(download.name, 'localhost')
		self.assertEqual(download.state, 'Finished')
Beispiel #2
0
def submit_new_download(request):
	try:
		download_url = request.POST['download_url']
		download_type = request.POST['download_type']
	except (KeyError):
		return render(request, 'downloader/new_download.html', {
			'error_message': "You didn't select a download type.",
		})

	if download_type == "simple_url_download":
		download = SimpleUrlDownload.create(download_url)
	else:
		return render(request, 'downloader/new_download.html', {
			'error_message': "Unsupported download type.",
		})
	download.save()
	download.start()

	return HttpResponseRedirect(reverse('downloader:downloads_list'))