def setup_profiles(db, entries, main_uid): db.execute("delete from entries;delete from cache_entries;") db.commit() user1 = db.query(M.User).get(main_uid) user2 = None therapists = Box() for k in 'other therapist_vr therapist_cbt therapist_mix therapist_na'.split( ): user = M.User(id=uuid4(), **fixtures.users[k]) if k == 'other': user2 = user else: user.therapist = True therapists[k] = user db.add(user) db.commit() for k, v in entries.items(): entry = M.Entry(title=k, text=v.text) if k.startswith('Virtual_reality'): entry.user_id = main_uid elif k.startswith('Cognitive_behavioral_therapy'): entry.user_id = user2.id else: continue db.add(entry) db.commit() e_p.entries() e_p.profiles() return user1, user2, therapists
def main_uid(db): db.execute("delete from users") db.commit() for k in 'entries cache_entries cache_users fields influencers'.split(): sql = f"select count(*) as ct from {k}" assert db.execute(sql).fetchone().ct == 0 u = M.User(id=uuid4(), **fixtures.users.user) db.add(u) db.commit() return str(u.id)
import common import common.validators as validators import common.models as models # from common.models import * import common.helpers as helpers validators.is_boolean('true') validators.is_json('{}') validators.is_numeric(10) validators.is_date('2018-0101') john_post = models.Post() john_posts = models.Posts() john = models.User() print('\n\n***** self *****') for k in dict(globals()).keys(): print(k) print('\n\n***** common *****') for k in common.__dict__.keys(): print(k) print('\n\n***** models *****') for k in common.models.__dict__.keys(): print(k)