def setUp(self): self.app_context = app.app_context() self.app_context.push() self.flush_database() app.database.create_collection('users') app.database.create_collection('posts') app.database.create_collection('buy_states') app.database.create_collection('buys') app.database.create_collection('questions') app.database.create_collection('scores') self.setUpDbEnviroment()
import base64 import datetime import logging import re import time from io import BytesIO import qrcode from bson.son import SON from server.setup import app logging.basicConfig(filename='debug.log', level=logging.DEBUG) with app.app_context(): workingCollection = app.database.posts class PostTransactions: def __init__(self): pass @staticmethod def __validate_estado(estado): return estado in ["activo", "pausado", "cancelado"] @staticmethod def __parse_data(data): parsed_data = {} if "title" in data.keys() and data["title"] is not None: parsed_data["title"] = data["title"] if "desc" in data.keys() and data["desc"] is not None: parsed_data["description"] = data["desc"]