Пример #1
0
 def setup_device(self):
     self.device = testobjects.make_mock_device()
     self.sync = self.device.database[u'sync'] = devices.DeviceDatabase()
     self.sync[u'podcasts'] = devices.DeviceDatabase()
     self.sync[u'playlists'] = devices.DeviceDatabase()
     self.sync[u'podcasts'][u'all'] = True
     self.sync[u'podcasts'][u'enabled'] = True
     self.sync[u'podcasts'][u'expire'] = True
     self.sync[u'podcasts'][u'items'] = [self.feed.url]
     self.sync[u'playlists'][u'enabled'] = True
     self.sync[u'playlists'][u'items'] = [self.playlist.title]
Пример #2
0
def make_mock_device(no_database=False):
    mount = current_test.make_temp_dir_path()
    os.makedirs(os.path.join(mount, '.miro'))
    os.makedirs(os.path.join(mount, 'cover-art'))
    device = messages.DeviceInfo(123, make_devices_device_info(), mount,
                                 devices.sqlite_database_path(mount),
                                 devices.DeviceDatabase(), None, None, 1024000,
                                 512000, False)
    if not no_database:
        setup_mock_device_database(device)
    return device
Пример #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
    device_databases_created.append(sqlite_db)
    return device
Пример #4
0
 def setup_json_db(self, path):
     # setup a device database
     json_path = resources.path(path)
     self.device.db = devices.DeviceDatabase(json.load(open(json_path)))