コード例 #1
0
ファイル: tests.py プロジェクト: akashin/Download-Server
	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')
コード例 #2
0
ファイル: views.py プロジェクト: akashin/Download-Server
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'))