def setUp(self): os.environ['PY4WEB_APPS_FOLDER'] = 'apps' self.db = DAL('sqlite:memory') self.session = Session(secret="a", expiration=10) self.session.local.data = {} self.auth = Auth(self.session, self.db, define_tables=True) self.auth.enable() request.app_name = '_scaffold'
def setUp(self): os.environ["PY4WEB_APPS_FOLDER"] = "apps" self.db = DAL("sqlite:memory") self.session = Session(secret="a", expiration=10) self.session.local.data = {} self.auth = Auth(self.session, self.db, define_tables=True, password_complexity=None) self.auth.enable() request.app_name = "_scaffold"
def test_extra_fields(self): self.db = DAL("sqlite:memory") self.session = Session(secret="a", expiration=10) self.session.local.data = {} self.auth = Auth(self.session, self.db, define_tables=True, extra_fields=[Field('favorite_color')]) self.assertEqual(type(self.db.auth_user.favorite_color), Field)
def setUp(self): os.environ["PY4WEB_APPS_FOLDER"] = "apps" _before_request() # mimic before_request bottle-hook self.db = DAL("sqlite:memory") self.session = Session(secret="a", expiration=10) self.session.initialize() self.auth = Auth(self.session, self.db, define_tables=True, password_complexity=None) self.auth.enable() self.auth.action = self.action request.app_name = "_scaffold"
from py4web import __version__, action, abort, request, response, redirect, Translator, HTTP, URL from py4web.core import Reloader, dumps, ErrorStorage, Session, Fixture from py4web.utils.factories import ActionFactory from pydal.validators import CRYPT from yatl.helpers import BEAUTIFY from .utils import * from .diff2kryten import diff2kryten MODE = os.environ.get("PY4WEB_DASHBOARD_MODE", "none") FOLDER = os.environ["PY4WEB_APPS_FOLDER"] APP_FOLDER = os.path.dirname(__file__) T_FOLDER = os.path.join(APP_FOLDER, "translations") T = Translator(T_FOLDER) error_storage = ErrorStorage() db = error_storage.db session = Session() def run(command, project): """for runing git commands inside an app (project)""" return subprocess.check_output(command.split(), cwd=os.path.join(FOLDER, project)).decode() def get_commits(project): """list of git commits for the project""" output = run("git log", project) commits = [] for line in output.split("\n"): if line.startswith("commit "): commit = {