Ejemplo n.º 1
0
class TestDeezerConfig(object):

    def setup(self):
        self.path = './tests/testcfg.ini'
        with pytest.raises(SystemExit):
            DeezerConfig(self.path)
        self.cfg = DeezerConfig(self.path)

    def teardown(self):
        if os.path.isfile(self.path):
            os.remove(self.path)

    def test_default_data(self):
        # assert data is not empty Dict
        assert self.cfg.get()
        assert isinstance(self.cfg.get(), Dict)
Ejemplo n.º 2
0
def main(custom_args=None, config_path=CONFIG_PATH):
    global DEBUG_MODE

    try:
        parser = build_cli_parser()
        args = parser.parse_args(custom_args)

        if args.debug:
            DEBUG_MODE = True

        config = DeezerConfig(config_path, printer=printer)

        if args.version:
            printer.print('version: {0}'.format(SCRIPT_VERSION))
            sys.exit()

        if args.edit:
            edit_config(config, args.editor)
            sys.exit()

        if not args.scenario and not args.list:
            print_help_and_exit(parser)

        dz = DeezerScenario(config)

        if args.list:
            print_list_scenarios(dz, args.verbous)
            sys.exit()

        if args.scenario:
            process_cli_scenario_call(args.scenario, dz, args.info)
            sys.exit()

    except DeezerApiRequestError as e:
        handle_exception_output(e)
    except Exception as e:
        raise (e)
Ejemplo n.º 3
0
 def setup(self):
     self.path = './tests/testcfg.ini'
     with pytest.raises(SystemExit):
         DeezerConfig(self.path)
     self.cfg = DeezerConfig(self.path)
Ejemplo n.º 4
0
 def setup(self):
     assert not os.path.isfile(self.config_path)
     with pytest.raises(SystemExit):
         DeezerConfig(self.config_path)
     self.config = DeezerConfig(self.config_path)
     self.tool = DeezerTool(self.config)
Ejemplo n.º 5
0
 def setup(self):
     with pytest.raises(SystemExit):
         DeezerConfig(self.config_path)
     config = DeezerConfig(self.config_path)
     self.sc = DeezerScenario(config)
Ejemplo n.º 6
0
def edit_config(config: DeezerConfig, editor=None):
    if not editor:
        editor = config.get('system', 'editor')
    p = subprocess.Popen([editor, config.path])
    return p.wait()
Ejemplo n.º 7
0
 def setup(self):
     with pytest.raises(SystemExit):
         DeezerConfig(self.config_path)
     config = DeezerConfig(self.config_path)
     self.pl = DeezerPlaylist(config)