示例#1
0
def initialize():
    """Initializes database file"""
    # Deletes database file if exists.
    if os.path.isfile("books.db"): os.unlink("books.db")

    # Initializes Macaron
    macaron.macaronage("books.db")

    # Creates tables
    macaron.execute(SQL_T_TAG)
    macaron.execute(SQL_T_BOOK)

    # Initial data
    tag1 = Tag.create(name="Python")
    tag1.books.append(title="Learning Python",
                      description="Powerful Object-Oriented Programming",
                      rating=5)
    tag1.books.append(title="Expert Python Programming",
                      description="Python best practice for experts.",
                      rating=4)
    tag2 = Tag.create(name="Japanese")
    tag2.books.append(title="K-ON!",
                      description="Highschool band cartoon.",
                      rating=5)

    # Commits
    macaron.bake()
示例#2
0
 def _compare_schema(self, tbl_name, sql_lines):
     cur = macaron.execute("SELECT sql FROM sqlite_master WHERE name = ?", [tbl_name])
     tbl_lines = cur.fetchone()[0].splitlines()
     self.assertEqual(len(tbl_lines), len(sql_lines))
     cnt = 0
     for line in tbl_lines:
         self.assertEqual(line, sql_lines.pop(0))
         cnt += 1
     self.assertEqual(cnt, len(tbl_lines))
     self.assertEqual(len(sql_lines), 0)
示例#3
0
def initialize():
    """Initializes database file"""
    # Deletes database file if exists.
    if os.path.isfile("books.db"): os.unlink("books.db")

    # Initializes Macaron
    macaron.macaronage("books.db")

    # Creates tables
    macaron.execute(SQL_T_TAG)
    macaron.execute(SQL_T_BOOK)

    # Initial data
    tag1 = Tag.create(name="Python")
    tag1.books.append(title="Learning Python", description="Powerful Object-Oriented Programming", rating=5)
    tag1.books.append(title="Expert Python Programming", description="Python best practice for experts.", rating=4)
    tag2 = Tag.create(name="Japanese")
    tag2.books.append(title="K-ON!", description="Highschool band cartoon.", rating=5)

    # Commits
    macaron.bake()
示例#4
0
 def setUp(self):
     macaron.macaronage(DB_FILE, lazy=True)
     macaron.execute(SQL_TEAM)
     macaron.execute(SQL_MEMBER)
示例#5
0
 def testLogger_content(self):
     macaron.macaronage(DB_FILE, history=10)
     macaron.execute(SQL_TEST)
     self.assertEqual(macaron.history[0], "%s\nparams: []" % SQL_TEST)
     macaron.cleanup()
示例#6
0
 def setUp(self):
     macaron.macaronage(dbfile=DB_FILE, lazy=True)
     macaron.execute(sql_t_team)
     macaron.execute(sql_t_member)
示例#7
0
 def setUp(self):
     macaron.macaronage(dbfile=DB_FILE, lazy=True)
     macaron.execute(sql_t_myrecord)
示例#8
0
 def testLoggerWithMacaron(self):
     macaron.macaronage(DB_FILE, history=10)
     macaron.execute(SQL_TEST)
     self.assertEqual(str(macaron.history[0]), "%s\nparams: []" % SQL_TEST)
     macaron.cleanup()
示例#9
0
 def testLogger_content(self):
     macaron.macaronage(DB_FILE, history=10)
     macaron.execute(SQL_TEST)
     self.assertEqual(str(macaron.history[0]), "%s\nparams: []" % SQL_TEST)
     macaron.cleanup()