def setUp(self): self.request = testing.DummyRequest() self.request.user = None self.config = testing.setUp(request=self.request) self.config.include('pyconca') engine = create_engine('sqlite://') DBSession.configure(bind=engine) from pyconca.models import ( Base, User, UserGroup, Group, ) Base.metadata.create_all(engine) with transaction.manager: self._admin_id = 1 self._speaker_id = 2 for model in ( User(id=self._admin_id, username='******', password='', first_name='Admin', last_name='Istrator', email='*****@*****.**'), User(id=self._speaker_id, username='******', password='', first_name='Spe', last_name='Aker', email='*****@*****.**'), Group(id=1, name='admin'), UserGroup(user_id=self._admin_id, group_id=1), ): DBSession.add(model)
def setUp(self): self.request = testing.DummyRequest() self.request.user = None self.config = testing.setUp(request=self.request) self.config.include('pyconca') engine = create_engine('sqlite://') DBSession.configure(bind=engine) from pyconca.models import ( Base, User, UserGroup, Group, Talk ) Base.metadata.create_all(engine) with transaction.manager: self._admin_id = 1 self._speaker_id = 2 for model in ( User(id=self._admin_id, username='******', password='', first_name='Admin', last_name='Istrator', email='*****@*****.**'), User(id=self._speaker_id, username='******', password='', first_name='Spe', last_name='Aker', email='*****@*****.**'), Group(id=1, name='admin'), UserGroup(user_id=self._admin_id, group_id=1), Talk(id=self._admin_id, owner_id=self._admin_id, title='Admin Title', type='talk', level='experienced', abstract='Abstract', outline='Outline', reviewer_notes='Reviewed?'), Talk(id=self._speaker_id, owner_id=self._speaker_id, title='Speaker Title', type='tutorial', level='novice', abstract='Strabact', outline='Silhouette', reviewer_notes='Viewed again.'), ): DBSession.add(model)
def main(argv=sys.argv): from pyconca.models import DBSession, ScheduleSlot, Talk, TalkScheduleSlot ignore_errors = False if "--ignore-errors" in argv: argv.remove("--ignore-errors") ignore_errors = True if len(argv) != 2: usage(argv) return 1 if "--dry-run" in argv: print "\n".join(map(str, parse_schedule(schedule))) return 0 config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) dumpdb = os.path.join(os.path.dirname(__file__), "../../prod_mysqldump") if os.path.exists(dumpdb): print "Running %r..." % (dumpdb, ) res = os.system(dumpdb) if res: return res with transaction.manager: for slot in parse_schedule(schedule): s = DBSession.query(ScheduleSlot).filter_by(code=slot.code).first() if s is None: s = ScheduleSlot() vals = slot._asdict() talk = vals.pop("talk") s.__dict__.update(vals) DBSession.add(s) if talk: t = DBSession.query(Talk).filter_by(id=talk.id).first() if not t: if ignore_errors: continue raise Exception("invalid talk: %r" % (talk, )) actual_talk_owner = "%s %s" % (t.owner.first_name, t.owner.last_name) assert actual_talk_owner.lower() == talk.owner_name.lower(), \ "bad data? owners don't match: %r != %r" %( actual_talk_owner, talk.owner_name) ts = DBSession.query(TalkScheduleSlot).filter_by( talk_id=t.id).first() if not ts: ts = TalkScheduleSlot() ts.talk_id = t.id ts.schedule_slot = s DBSession.add(ts) DBSession.flush()
def main(argv=sys.argv): from pyconca.models import DBSession, ScheduleSlot, Talk, TalkScheduleSlot ignore_errors = False if "--ignore-errors" in argv: argv.remove("--ignore-errors") ignore_errors = True if len(argv) != 2: usage(argv) return 1 if "--dry-run" in argv: print "\n".join(map(str, parse_schedule(schedule))) return 0 config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) dumpdb = os.path.join(os.path.dirname(__file__), "../../prod_mysqldump") if os.path.exists(dumpdb): print "Running %r..." %(dumpdb, ) res = os.system(dumpdb) if res: return res with transaction.manager: for slot in parse_schedule(schedule): s = DBSession.query(ScheduleSlot).filter_by(code=slot.code).first() if s is None: s = ScheduleSlot() vals = slot._asdict() talk = vals.pop("talk") for (k, v) in vals.items(): setattr(s, k, v) DBSession.add(s) if talk: t = DBSession.query(Talk).filter_by(id=talk.id).first() if not t: if ignore_errors: continue raise Exception("invalid talk: %r" %(talk, )) actual_talk_owner = "%s %s" %(t.owner.first_name, t.owner.last_name) assert actual_talk_owner.lower() == talk.owner_name.lower(), \ "bad data? owners don't match: %r != %r" %( actual_talk_owner, talk.owner_name) ts = DBSession.query(TalkScheduleSlot).filter_by(talk_id=t.id).first() if not ts: ts = TalkScheduleSlot() ts.talk_id = t.id ts.schedule_slot = s DBSession.add(ts) DBSession.flush()
def setUp(self): self.request = testing.DummyRequest() self.request.user = None self.config = testing.setUp(request=self.request) self.config.include('pyconca') engine = create_engine('sqlite://') DBSession.configure(bind=engine) from pyconca.models import (Base, User, UserGroup, Group, Talk) Base.metadata.create_all(engine) with transaction.manager: self._admin_id = 1 self._speaker_id = 2 for model in ( User(id=self._admin_id, username='******', password='', first_name='Admin', last_name='Istrator', email='*****@*****.**'), User(id=self._speaker_id, username='******', password='', first_name='Spe', last_name='Aker', email='*****@*****.**'), Group(id=1, name='admin'), UserGroup(user_id=self._admin_id, group_id=1), Talk(id=self._admin_id, owner_id=self._admin_id, title='Admin Title', type='talk', level='experienced', abstract='Abstract', outline='Outline', reviewer_notes='Reviewed?'), Talk(id=self._speaker_id, owner_id=self._speaker_id, title='Speaker Title', type='tutorial', level='novice', abstract='Strabact', outline='Silhouette', reviewer_notes='Viewed again.'), ): DBSession.add(model)
def main(argv=sys.argv): from pyconca.models import DBSession, ScheduleSlot, Talk, TalkScheduleSlot if len(argv) != 2: usage(argv) sys.exit(1) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) with transaction.manager: for slot in parse_schedule(schedule): s = DBSession.query(ScheduleSlot).filter_by(code=slot.code).first() if s is None: s = ScheduleSlot() vals = slot._asdict() talk = vals.pop("talk") s.__dict__.update(vals) DBSession.add(s) if talk: t = DBSession.query(Talk).filter_by(id=talk.id).first() if not t: raise Exception("invalid talk: %r" % (talk, )) actual_talk_owner = "%s %s" % (t.owner.first_name, t.owner.last_name) assert actual_talk_owner.lower() == talk.owner_name.lower(), \ "bad data? owners don't match: %r != %r" %( actual_talk_owner, talk.owner_name) ts = DBSession.query(TalkScheduleSlot).filter_by( talk_id=t.id).first() if not ts: ts = TalkScheduleSlot() ts.talk_id = t.id ts.schedule_slot = s DBSession.add(ts) DBSession.flush()
def main(argv=sys.argv): from pyconca.models import DBSession, ScheduleSlot, Talk, TalkScheduleSlot if len(argv) != 2: usage(argv) sys.exit(1) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, "sqlalchemy.") DBSession.configure(bind=engine) with transaction.manager: for slot in parse_schedule(schedule): s = DBSession.query(ScheduleSlot).filter_by(code=slot.code).first() if s is None: s = ScheduleSlot() vals = slot._asdict() talk = vals.pop("talk") s.__dict__.update(vals) DBSession.add(s) if talk: t = DBSession.query(Talk).filter_by(id=talk.id).first() if not t: raise Exception("invalid talk: %r" % (talk,)) actual_talk_owner = "%s %s" % (t.owner.first_name, t.owner.last_name) assert ( actual_talk_owner.lower() == talk.owner_name.lower() ), "bad data? owners don't match: %r != %r" % (actual_talk_owner, talk.owner_name) ts = DBSession.query(TalkScheduleSlot).filter_by(talk_id=t.id).first() if not ts: ts = TalkScheduleSlot() ts.talk_id = t.id ts.schedule_slot = s DBSession.add(ts) DBSession.flush()