def test_allowed_extension(self):
   self.assertTrue(file_utils.allowed_file('tiikerikakku.JPG'))
   self.assertTrue(file_utils.allowed_file('tiikerikakku.jpg'))
   self.assertTrue(file_utils.allowed_file('tiikerikakku.png'))
   self.assertTrue(file_utils.allowed_file('tiikerikakku.PNG'))
   self.assertTrue(file_utils.allowed_file('tiikerikakku.GIF'))
   self.assertTrue(file_utils.allowed_file('tiikerikakku.gif'))
Exemple #2
0
def upload_file():	

	if not is_authenticated():
		return redirect('/')

	if request.method == 'POST':
		file = request.files['file']       

		if file and file_utils.allowed_file(file.filename):
			filename = secure_filename(file.filename)			
			app.logger.debug(os.path.join(app.config.get('UPLOAD_DIRECTORY'), filename))
			file.save(os.path.join(app.config.get('UPLOAD_DIRECTORY'), filename))
			app.logger.debug("Saved")

	files = file_utils.list_allowed_files()	
	return render_template('upload.html', user=g.user, 
								  files=files, 
								  error=request.args.get('error',''),
								  base_url=app.config.get('BASE_URL'))
 def test_unallowed_extension(self):
   self.assertFalse(file_utils.allowed_file('tiikerikakku'))
   self.assertFalse(file_utils.allowed_file(''))
   self.assertFalse(file_utils.allowed_file('mussutus.txt'))
   self.assertFalse(file_utils.allowed_file('mussutus.sh'))