Example #1
0
 def open_database(self):
     sqlite_db = devices.load_sqlite_database(self.device.mount,
                                              self.device.database,
                                              self.device.size)
     metadata_manager = devices.make_metadata_manager(self.device.mount,
                                                      sqlite_db,
                                                      self.device.id)
     self.device.sqlite_database = sqlite_db
     self.device.metadata_manager = metadata_manager
Example #2
0
def setup_mock_device_database(device):
    device.database = devices.DeviceDatabase()
    device.database[u'settings'] = {
        u'audio_path': os.path.join(device.mount, 'audio_path'),
        u'video_path': os.path.join(device.mount, 'video_path'),
    }
    sqlite_db = devices.load_sqlite_database(device.mount, device.size)
    db_info = database.DeviceDBInfo(sqlite_db, device.id)
    metadata_manager = devices.make_metadata_manager(device.mount, db_info,
                                                     device.id)
    device.db_info = db_info
    device.metadata_manager = metadata_manager
    device_databases_created.append(sqlite_db)
    return device
Example #3
0
def setup_mock_device_database(device):
    device.database = devices.DeviceDatabase()
    device.database[u'settings'] = {
        u'audio_path': os.path.join(device.mount, 'audio_path'),
        u'video_path': os.path.join(device.mount, 'video_path'),
    }
    sqlite_db = devices.load_sqlite_database(device.mount,
                                             device.size)
    db_info = database.DeviceDBInfo(sqlite_db, device.id)
    metadata_manager = devices.make_metadata_manager(device.mount,
                                                     db_info,
                                                     device.id)
    device.db_info = db_info
    device.metadata_manager = metadata_manager
    return device
Example #4
0
    def check_json_import(self, device_data):
        """Check that we successfully imported the sqlite data."""
        sqlite_db = devices.load_sqlite_database(self.device.mount, 1024)
        sqlite_db.cursor.execute("SELECT album from metadata")
        db_info = database.DeviceDBInfo(sqlite_db, self.device.id)
        importer = devicedatabaseupgrade.OldItemImporter(
            sqlite_db, self.device.mount, self.device.db)
        importer.import_metadata()
        metadata_manager = devices.make_metadata_manager(
            self.device.mount, db_info, self.device.id)
        importer.import_device_items(metadata_manager)

        for path, item_data in device_data.items():
            # fill in data that's implicit with the dict
            item_data['file_type'] = u'audio'
            item_data['video_path'] = path
            filename = utf8_to_filename(path.encode('utf-8'))
            self.check_migrated_status(filename, db_info)
            self.check_migrated_entries(filename, item_data, db_info)
            self.check_migrated_device_item(filename, item_data, db_info)
            # check that the title tag was deleted
            self.assert_(not hasattr(item, 'title_tag'))
Example #5
0
    def check_json_import(self, device_data):
        """Check that we successfully imported the sqlite data."""
        sqlite_db = devices.load_sqlite_database(self.device.mount, 1024)
        sqlite_db.cursor.execute("SELECT album from metadata")
        db_info = database.DeviceDBInfo(sqlite_db, self.device.id)
        importer = devicedatabaseupgrade.OldItemImporter(sqlite_db,
                                                         self.device.mount,
                                                         self.device.db)
        importer.import_metadata()
        metadata_manager = devices.make_metadata_manager(self.device.mount,
                                                         db_info,
                                                         self.device.id)
        importer.import_device_items(metadata_manager)

        for path, item_data in device_data.items():
            # fill in data that's implicit with the dict
            item_data['file_type'] = u'audio'
            item_data['video_path'] = path
            filename = utf8_to_filename(path.encode('utf-8'))
            self.check_migrated_status(filename, db_info)
            self.check_migrated_entries(filename, item_data, db_info)
            self.check_migrated_device_item(filename, item_data, db_info)
            # check that the title tag was deleted
            self.assert_(not hasattr(item, 'title_tag'))