コード例 #1
0
ファイル: playtest.py プロジェクト: Gavin1123/chromabot
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
コード例 #2
0
ファイル: playtest.py プロジェクト: atiaxi/chromabot
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))
コード例 #3
0
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))
コード例 #4
0
ファイル: add_teaminfo.py プロジェクト: atiaxi/chromabot
def create():
    c = Config()

    dbconn = DB(c)

    sess = dbconn.session()

    # Create team DB entries
    TeamInfo.create_defaults(sess, c)
コード例 #5
0
ファイル: patch_regions.py プロジェクト: atiaxi/chromabot
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)
コード例 #6
0
ファイル: patch_regions.py プロジェクト: Gavin1123/chromabot
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)
コード例 #7
0
    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)
コード例 #8
0
ファイル: playtest.py プロジェクト: atiaxi/chromabot
    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)
コード例 #9
0
ファイル: add_teaminfo.py プロジェクト: atiaxi/chromabot
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"
コード例 #10
0
ファイル: bootstrap.py プロジェクト: atiaxi/chromabot
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()
コード例 #11
0
ファイル: bootstrap.py プロジェクト: atiaxi/chromabot
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()