def tearDown(self): super(DestinationTest, self).tearDown() self.lib._connection().close() # Reset config if it was changed in test cases config.clear() config.read(user=False, defaults=True)
def setUp(self): config.clear() config.read(user=False) self.importfeeds = ImportFeedsPlugin() self.lib = Library(':memory:') self.feeds_dir = tempfile.mkdtemp() config['importfeeds']['dir'] = self.feeds_dir
def setUp(self): config.clear() self.setup_beets() config["subsonic"]["user"] = "******" config["subsonic"]["pass"] = "******" config["subsonic"]["url"] = "http://localhost:4040" self.subsonicupdate = subsonicupdate.SubsonicUpdate()
def setUp(self): """Sets up config and plugin for test.""" config.clear() self.setup_beets() config["subsonic"]["user"] = "******" config["subsonic"]["pass"] = "******" config["subsonic"]["url"] = "http://localhost:4040" self.subsonicupdate = subsonicupdate.SubsonicUpdate()
def test_edit_invalid_config_file(self): with open(self.config_path, 'w') as file: file.write('invalid: [') config.clear() config._materialized = False os.environ['EDITOR'] = 'myeditor' with patch('os.execlp') as execlp: self.run_command('config', '-e') execlp.assert_called_once_with('myeditor', 'myeditor', self.config_path)
def test_edit_invalid_config_file(self): with open(self.config_path, 'w') as file: file.write('invalid: [') config.clear() config._materialized = False os.environ['EDITOR'] = 'myeditor' with patch('os.execlp') as execlp: self.run_command('config', '-e') execlp.assert_called_once_with( 'myeditor', 'myeditor', self.config_path)
def setUp(self): """Sets up config and plugin for test.""" config.clear() self.setup_beets() config["subsonic"]["user"] = "******" config["subsonic"]["pass"] = "******" config["subsonic"]["url"] = "http://localhost:4040" responses.add(responses.GET, 'http://localhost:4040/rest/ping.view', status=200, body=self.PING_BODY) self.subsonicupdate = subsonicupdate.SubsonicUpdate()
def beet_import(album_dir: Path, logger): ''' Emulates the behaviour of calling Beets' import function from a shell, in an embedded fashion. This bypasses a lot of the overhead required in creating a new subprocess as well as for other set up. Since the default beets config and library are used, no custom processing is required to set those up. Behind the scenes, beets will open a :code:`beets.ui.commands.TerminalImportSession` so that users can enter input via stdin. That function will emit the cli_exit event in case the user has activated any plugins that rely on this event. All of this functionality is emulated here. Args: album_dir (Path): A path to an album directory where some music exists logger: A logging object ''' import_dir = str(Path(album_dir).parent.parent.resolve()).replace( '\\', '/') beetsplug_dir = str(Path(beetsplug.__file__).parent.resolve()).replace( '\\', '/') config_content = get_custom_config_contents(import_dir=import_dir, beetsplug_dir=beetsplug_dir) with TemporaryDirectory() as temp_dir: temp_file_path = os.path.join(temp_dir, 'config.yaml') with open(temp_file_path, 'w', encoding='utf-8') as temp_config: temp_config.write(config_content) logger.debug(msg=( 'Created a temporary beets config at: {0}'.format(temp_file_path))) setup_options = ArgparseNamespace( directory=None, config=temp_file_path, plugins=None, library=None, ) _, plugins, library = setup_beets(setup_options) # Start the import paths = [str(album_dir).encode('utf-8')] import_files(library, paths, None) # Clean up plugins.send('cli_exit', lib=library) library._close() beetsconfig.clear()
def setUp(self): self.temp_dir = mkdtemp() if 'EDITOR' in os.environ: del os.environ['EDITOR'] os.environ['BEETSDIR'] = self.temp_dir self.config_path = os.path.join(self.temp_dir, 'config.yaml') with open(self.config_path, 'w') as file: file.write('library: lib\n') file.write('option: value') self.cli_config_path = os.path.join(self.temp_dir, 'cli_config.yaml') with open(self.cli_config_path, 'w') as file: file.write('option: cli overwrite') config.clear() config._materialized = False
def setUp(self): config.clear() self.setup_beets() responses.add( responses.POST, spotify.SpotifyPlugin.oauth_token_url, status=200, json={ 'access_token': '3XyiC3raJySbIAV5LVYj1DaWbcocNi3LAJTNXRnYY' 'GVUl6mbbqXNhW3YcZnQgYXNWHFkVGSMlc0tMuvq8CF', 'token_type': 'Bearer', 'expires_in': 3600, 'scope': '', }, ) self.spotify = spotify.SpotifyPlugin() opts = ArgumentsMock("list", False) self.spotify._parse_opts(opts)
def tearDown(self): config.clear() self.unload_plugins()
def _reset_config(self): # Config should read files again on demand config.clear() config._materialized = False
def setUp(self): config.clear() self.setup_beets() self.spotify = spotify.SpotifyPlugin() opts = ArgumentsMock("list", False) self.spotify.parse_opts(opts)