def parse(): f = request.files['file'] if allowed_extensions(f.filename): filename = secure_filename(f.filename) f.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) response = Log.process(app.config['UPLOAD_FOLDER'] + "/" + f.filename) success = True else: response = 'Invalid extension' success = False return formatResponse(response, success)
def testInsertLogSuccess(self): Dal = Mongo(self.log.collectionName) Log = self.log(Dal) self.assertEqual(len(str(Log.process('/app/fileToSend/log.txt'))), 24)
def testInsertLogFail(self): Dal = Mongo(self.log.collectionName) Log = self.log(Dal) with self.assertRaises(OSError): Log.process('/app/fileToSend/arquivoinexistente.txt')