def setUp(self): extra_env = cfg.test_environment(self.workdir) extra_env['LANG'] = 'en_GB.utf8' self.sandbox = trackertestutils.helpers.TrackerDBusSandbox( session_bus_config_file=cfg.TEST_DBUS_DAEMON_CONFIG_FILE, extra_env=extra_env) self.sandbox.start() try: # It's important that this directory exists BEFORE we start Tracker: # it won't monitor an indexing root for changes if it doesn't exist, # it'll silently ignore it instead. See the tracker_crawler_start() # function. os.makedirs(self.indexed_dir, exist_ok=True) self.sandbox.set_config(self.config()) self.miner_fs = MinerFsHelper(self.sandbox.get_session_bus_connection()) self.miner_fs.start() self.miner_fs.start_watching_progress() self.tracker = trackertestutils.helpers.StoreHelper( self.miner_fs.get_sparql_connection()) except Exception: self.sandbox.stop() raise
def setUp(self): super(TrackerCommandLineTestCase, self).setUp() extra_env = cfg.test_environment(self.workdir) extra_env['LANG'] = 'en_GB.utf8' self.env = os.environ.copy() self.env.update(extra_env) path = self.env.get('PATH', []).split(':') self.env['PATH'] = ':'.join([cfg.cli_dir()] + path) self.env['TRACKER_CLI_SUBCOMMANDS_DIR'] = cfg.cli_subcommands_dir()
def test_external_cue_sheet(self): with tempfile.TemporaryDirectory() as tmpdir: datadir = pathlib.Path(__file__).parent.joinpath('test-extraction-data') shutil.copy(datadir.joinpath('audio', 'cuesheet-test.cue'), tmpdir) audio_path = pathlib.Path(tmpdir).joinpath('cuesheet-test.flac') datagenerator.create_test_flac(audio_path, duration=6*60) result = fixtures.get_tracker_extract_output( cfg.test_environment(tmpdir), audio_path, output_format='json-ld') self.assert_extract_result_matches_spec( self.spec(audio_path), result, audio_path, __file__)
def generic_test_extraction(self): abs_description = os.path.abspath(self.descfile) # Filename contains the file to extract, in a relative path to the description file desc_root, desc_file = os.path.split(abs_description) filename_to_extract = self.spec['test']['Filename'] self.file_to_extract = os.path.join(desc_root, filename_to_extract) tmpdir = tempfile.mkdtemp(prefix='tracker-extract-test-') try: extra_env = cfg.test_environment(tmpdir) result = fixtures.get_tracker_extract_jsonld_output( extra_env, self.file_to_extract) self.__assert_extraction_ok(result) finally: shutil.rmtree(tmpdir, ignore_errors=True)
def environment(self): extra_env = cfg.test_environment(self.workdir) extra_env['LANG'] = 'en_GB.utf8' return extra_env