def test_app_config(self): try: app = AppConfig('tests/app_config.json') self.assertEqual( app.get_value('question_lines','start') , 2 ) self.assertEqual( app.get_value('question_lines','end') , 6 ) self.assertEqual( app.get_value('paragraph_length'),5000) self.assertEqual(True,True) except Exception as e: print e traceback.print_exc(file=sys.stdout) self.assertEqual(False,'Shoutd not fail') try: self.assertEqual( app.get_value('paragraph_length',2323),5000) self.assertEqual(False,'Shoud fail') except: self.assertEqual(True,True)
from flask_cors import CORS from app_config import AppConfig from app_exception import AppException from dao.mongo_repository import MongoRepository from services.anagram_service import AnagramService from tools.decorators import log_function # Define flask, cors, config and logger app = Flask(__name__) cors = CORS(app, resources={r"/api/*": {"origins": "*"}}) config = AppConfig() logger = config.get_log('app') # Connect to database db = MongoRepository(config.get_value('app', 'connection_database')) # Init service words = db.get_words_list() anagram_service = AnagramService(words) @app.route('/api/testdata') def fill_database(): """ Fill database with data test :return: 200 ok or exception """ try: data = [{'word': 'foo'}, {'word': 'bar'}, {'word': 'xyzzy'}]