# Path: chirp/library/audio_file_test.py
# TESTDATA = os.path.join(ROOT_DIR, "library/testdata/audio_file_test")
# TEST_VOL = 65
# TEST_TS = 1230430574
# TEST_FP = "7" * 40
# TEST_UFID = ufid.ufid(TEST_VOL, TEST_TS, TEST_FP)
# TEST_UFID_PREFIX = ufid.ufid_prefix(TEST_VOL, TEST_TS)
# def get_test_audio_file(n):
#     def test_basic(self):
#     def test_tag_accessors(self):
#     def test_scan_fast_tag_handling(self):
#     def test_scan_no_chirp_tags(self):
#     def test_scan_has_chirp_tags(self):
# class AudioFileTest(unittest.TestCase):
#         class MockInfo(object): pass
# 
# Path: chirp/library/database.py
# def _insert(target, table_name, insert_tuple):
# def _insert_tags(conn, fingerprint, timestamp, mutagen_id3):
# def _get_tags(conn, au_file, cutoff_timestamp):
# def _audio_file_generator(conn, sql):
#     def __init__(self, name):
#     def _get_connection(self):
#     def create_tables(self):
#     def get_all(self):
#     def get_all_imports(self):
#     def get_by_import(self, vol, import_timestamp):
#     def get_by_fingerprint(self, fingerprint):
#     def begin_add(self, volume, import_timestamp):
#     def update(self, au_file, timestamp):
#     def __init__(self, volume, import_timestamp, conn):
#     def add(self, au_file):
#     def commit(self):
#     def revert(self):
# class Database(object):
# class _AddTransaction(object):


import os
import time
import unittest
import mutagen.id3
from chirp.library import audio_file_test
from chirp.library import database

        add_txn = self.db.begin_add(test_volume, test_import_timestamp)
        for au_file in all_au_files:
            add_txn.add(au_file)
        add_txn.revert()
        # Should still be empty after reverting.
        self.assertEqual([], list(self.db.get_all()))

        for au_file in all_au_files:
            au_file.volume = None
            au_file.import_timestamp = None

        add_txn = self.db.begin_add(test_volume, test_import_timestamp)
        for au_file in all_au_files:
            add_txn.add(au_file)
        add_txn.commit()

        # Should be able to get_all.
        self.assert_same_audio_files(
            all_au_files,
            list(self.db.get_all()))

        # Should be able to get each file by fingerprint.
        for au_file in all_au_files:
            fetched_au_file = self.db.get_by_fingerprint(au_file.fingerprint)
            self.assertEqual(au_file, fetched_au_file)

    def test_update(self):
        self.assertTrue(self.db.create_tables())


# Path: chirp/library/audio_file_test.py
# TESTDATA = os.path.join(ROOT_DIR, "library/testdata/audio_file_test")
# TEST_VOL = 65
# TEST_TS = 1230430574
# TEST_FP = "7" * 40
# TEST_UFID = ufid.ufid(TEST_VOL, TEST_TS, TEST_FP)
# TEST_UFID_PREFIX = ufid.ufid_prefix(TEST_VOL, TEST_TS)
# def get_test_audio_file(n):
#     def test_basic(self):
#     def test_tag_accessors(self):
#     def test_scan_fast_tag_handling(self):
#     def test_scan_no_chirp_tags(self):
#     def test_scan_has_chirp_tags(self):
# class AudioFileTest(unittest.TestCase):
#         class MockInfo(object): pass
# 
# Path: chirp/library/database.py
# def _insert(target, table_name, insert_tuple):
# def _insert_tags(conn, fingerprint, timestamp, mutagen_id3):
# def _get_tags(conn, au_file, cutoff_timestamp):
# def _audio_file_generator(conn, sql):
#     def __init__(self, name):
#     def _get_connection(self):
#     def create_tables(self):
#     def get_all(self):
#     def get_all_imports(self):
#     def get_by_import(self, vol, import_timestamp):
#     def get_by_fingerprint(self, fingerprint):
#     def begin_add(self, volume, import_timestamp):
#     def update(self, au_file, timestamp):
#     def __init__(self, volume, import_timestamp, conn):
#     def add(self, au_file):
#     def commit(self):
#     def revert(self):
# class Database(object):
# class _AddTransaction(object):


# Path: chirp/library/database_test.py
import os
import time
import unittest
import mutagen.id3
from chirp.library import audio_file_test
from chirp.library import database


        add_txn = self.db.begin_add(test_volume, test_import_timestamp)
        for au_file in all_au_files:
            add_txn.add(au_file)
        add_txn.revert()
        # Should still be empty after reverting.
        self.assertEqual([], list(self.db.get_all()))

        for au_file in all_au_files:
            au_file.volume = None
            au_file.import_timestamp = None

        add_txn = self.db.begin_add(test_volume, test_import_timestamp)
        for au_file in all_au_files:
            add_txn.add(au_file)
        add_txn.commit()

        # Should be able to get_all.
        self.assert_same_audio_files(
            all_au_files,
            list(self.db.get_all()))

        # Should be able to get each file by fingerprint.
        for au_file in all_au_files:
            fetched_au_file = self.db.get_by_fingerprint(au_file.fingerprint)
            self.assertEqual(au_file, fetched_au_file)

    def test_update(self):
        self.assertTrue(self.db.create_tables())


        test_au_file = audio_file_test.get_test_audio_file(123)