class ChromaTest(unittest.TestCase): def setUp(self): logging.basicConfig(level=logging.DEBUG) self.conf = MockConf(dbstring="sqlite://") self.db = DB(self.conf) self.db.create_all() self.sess = self.db.session() self.sess.add_all(Region.create_from_json(TEST_LANDS)) self.sess.commit() # Create some users self.alice = self.create_user("alice", 0) self.bob = self.create_user("bob", 1) def create_user(self, name, team): newbie = User(name=name, team=team, loyalists=100, leader=True) self.sess.add(newbie) cap = Region.capital_for(team, self.sess) newbie.region = cap self.sess.commit() return newbie def get_region(self, name): name = name.lower() region = self.sess.query(Region).filter_by(name=name).first() return region
class ChromaTest(unittest.TestCase): def setUp(self): logging.basicConfig(level=logging.DEBUG) self.conf = MockConf(dbstring="sqlite://") self.db = DB(self.conf) self.db.create_all() self.sess = self.db.session() Region.create_from_json(self.sess, TEST_LANDS) # Create some users self.alice = self.create_user("alice", 0) self.bob = self.create_user("bob", 1) def create_user(self, name, team): newbie = User(name=name, team=team, loyalists=100, leader=True) self.sess.add(newbie) cap = Region.capital_for(team, self.sess) newbie.region = cap self.sess.commit() return newbie def context(self, player=None, comment=None, config=None): if not player: player = self.alice if not config: config = self.conf return MockContext(player, config, self.sess, comment) def get_region(self, name, as_who=None): if not as_who: as_who = self.alice return Region.get_region(name, self.context(player=as_who))
def create(): c = Config() dbconn = DB(c) sess = dbconn.session() # Create team DB entries TeamInfo.create_defaults(sess, c)
def main(): c = Config() reddit = c.praw() dbconn = DB(c) sess = dbconn.session() source = sys.argv[1] regions = Region.patch_from_json(sess, json_file=source, verbose=True)
def setUp(self): logging.basicConfig(level=logging.DEBUG) self.conf = MockConf(dbstring="sqlite://") self.db = DB(self.conf) self.db.create_all() self.sess = self.db.session() Region.create_from_json(self.sess, TEST_LANDS) # Create some users self.alice = self.create_user("alice", 0) self.bob = self.create_user("bob", 1)
def update(): c = Config() dbconn = DB(c) sess = dbconn.session() # Create team DB entries ora = sess.query(TeamInfo).filter_by(id=0).first() ora.greeting = """ Your team welcomes you! """ per = sess.query(TeamInfo).filter_by(id=1).first() per.greeting = """ Your team welcomes you! """ sess.commit() print "Greetings updated"
def main(): c = Config() reddit = c.praw() dbconn = DB(c) dbconn.drop_all() dbconn.create_all() sess = dbconn.session() source = sys.argv[1] regions = Region.create_from_json(sess, json_file=source) # Create team DB entries TeamInfo.create_defaults(sess, c) stamp()
def main(): c = Config() reddit = c.praw() dbconn = DB(c) dbconn.drop_all() dbconn.create_all() sess = dbconn.session() source = sys.argv[1] regions = Region.create_from_json(sess, json_file=source) stamp()