Esempio n. 1
0
    def assertConvertFilled(self, list_, results, dbfile="empty_draws.db"):
        dummy, clan, title = list_.split('.',2)
        db = suck_database(reldir(dbfile))
        converter = convert()
        converter.reset_db(db)
        list_ = relfile_list([list_])[0]
        converter.run(list_)
        for line in db.iterdump():
            if "INSERT" in line:
                print(line)
        cursor = self.cursor = db.cursor()

        sql = """select p1.userid, p2.userid
            from drawingresult as d
            join santalistdrawing as sld on (d.drawing = sld.listid)
            join clan on (clan.id = sl.clan)
            join person as p1 on (giver = p1.id)
            join person as p2 on (giftee = p2.id)
            join santalist as sl on (sld.listid = sl.id)
            where clan.clanname = ? and sl.listname = ? and sld.title = ?
            """
        #print(sql)
        #print(cursor.execute(sql,(clan, clan, title)).fetchall())
        dbresults = cursor.execute(sql, (clan, clan, title)).fetchall()

        self.assertEqual(dbresults, results)
Esempio n. 2
0
    def assertConvertFilled(self, files, members):
        clanname = ''.join(
            random.choice(string.ascii_letters) for _ in range(6))
        db = suck_database(reldir("empty_santalist.db"))
        cursor = db.cursor()
        cursor.execute(
            """insert into clan (clanname, description) values (?,?)""",
            (clanname, "Test clan"))
        converter = convert(clanname)
        converter.reset_db(db)
        files = relfile_list(files)
        converter.run(files)
        clanid = cursor.execute(
            "select id from clan where clanname = ?", (clanname,)).fetchone()[0]
        lists = cursor.execute(
            "select id, clan, listname from santalist").fetchall()
        self.assertEqual(len(lists), 1)
        self.assertEqual(lists[0][1], clanid)

        for file_, list_ in zip(files, lists):
            flname = os.path.splitext(file_.name)[1][1:]
            dblname = list_[2]
            self.assertEqual(flname, dblname)
            dbmembers = cursor.execute(
                """select person.userid from santalistmember join person on
                    (santalistmember.userid = person.id) where listid=?""",
                (list_[0],)).fetchall()
            dbmembers = [x[0] for x in dbmembers]
            self.assertCountEqual(dbmembers, members)
Esempio n. 3
0
 def assertConvertEmpty(self, files):
     db = suck_database(reldir("empty_santalist.db"))
     converter = convert('Clan1')
     converter.reset_db(db)
     files = relfile_list(files)
     converter.run(files)
     cursor = self.cursor = db.cursor()
     lists = cursor.execute("select listname from santalist").fetchall()
     self.assertEqual(len(lists), 0)
 def assertConverts(self, files, how_many=None):
     if how_many is None:
         how_many = len(files)
     db = suck_database(reldir("empty_tables.db"))
     converter = convert("")
     converter.reset_db(db)
     files = relfile_list(files)
     converter.run(files)
     # people table should be empty
     self.__mem = db.cursor()
     people = self.__mem.execute("select count(*) from person").fetchone()[0]
     self.assertEqual(people, how_many)
 def test_clan_created(self):
     db = suck_database(reldir("empty_tables.db"))
     self.__mem = db.cursor()
     self.assertNoClan('clan1')
     # Debug during development
     self.__mem.execute("""insert into clan (clanname)
         values ('Clan2'), ('Clan3')""")
     converter = convert("")
     converter.reset_db(db)
     files = relfile_list(['person.clanmember1'])
     converter.run(files)
     self.assertClanExists('Clan1')
     self.assertClanMember('Clan1', 'clanmember1')
Esempio n. 6
0
 def assertConverts(self,
                    files,
                    numwishes,
                    numgifts,
                    dbfile="empty_wishes.db"):
     db = suck_database(reldir(dbfile))
     #print("\n".join(db.iterdump()))
     converter = convert("")
     converter.reset_db(db)
     files = relfile_list(files)
     converter.run(files)
     cursor = db.cursor()
     wishes = cursor.execute("select count(*) from wish").fetchone()[0]
     self.assertEqual(wishes, numwishes)
     gifts = cursor.execute("select count(*) from gift").fetchone()[0]
     self.assertEqual(gifts, numgifts)