def test_config_is_singleton(): a = configuration.Configuration() b = configuration.Configuration() sth = a.interactive assert id(a) == id(b) b.interactive = not sth del a, b c = configuration.Configuration() assert c.interactive is not sth c.interactive = sth
def options_set(step, dryrun, verbose, interactive, target_dir, move): conf = configuration.Configuration() assert conf.dryrun is tobool(dryrun), dryrun assert conf.verbose is tobool(verbose), verbose assert conf.interactive is tobool(interactive), interactive assert conf.move is tobool(move), move assert conf.target_dir == target_dir, target_dir
def test_config_read_from_argument(): argv = "-f test2.cfg".split() parser = configuration.CmdlineParser() options = configuration.Configuration() assert options.interactive is False parser.parse(argv) assert 'test2.cfg' in options.cfg_files, options.cfg_files assert options.interactive is True options.interactive = False assert options.interactive is False
def test_arranger_mkpath(): tagm = make_my_tag() tag = arranger.Arranger(tagm) path = tag.makePath() assert path == "T/Test/2001-Test_Case/01.File.mp3", path tagm = make_my_tag() tagm.settag(artist="666 Tests", year=2001, album="Test case", track=1, title="6th test") tagm.filename = "test.ogg" tag = arranger.Arranger(tagm) path = tag.makePath() assert path == "0-9/666_Tests/2001-Test_Case/01.6Th_Test.ogg", path tagm.filename = "mh.fac" tagm.settag(title="whatever you want", track=5, artist="Test") tag = arranger.Arranger(tagm) path = tag.makePath() assert path == "" tagm.filename = u"höher.mp3" tagm.settag(title=u"Höher…", track=0, artist=u"Pilot", album=u"Über den Wolken") tag = arranger.Arranger(tagm) path = tag.makePath() assert path == "P/Pilot/Über_Den_Wolken/Höher….mp3" tagm.filename = "article test.ogg" tagm.settag(title="Foo bar", track=1, artist="Die sieben weltwunder", album="") options = configuration.Configuration() pat = options.newpath options.newpath = "{initial}/{artist},_{article}/{albumstyle}/{trackstyle}{title}" path = arranger.Arranger(tagm).makePath() assert path == "S/Sieben_Weltwunder,_Die//01.Foo_Bar.ogg", path options.newpath = pat
def test_config_and_parser(): options = configuration.Configuration() assert options.pattern == 'default-pattern', options.pattern assert options.dryrun is False assert options.move is False assert options.target_dir == './bla' parser = configuration.CmdlineParser() argv = "-nm -p multi file".split() files = parser.parse(argv) assert options.pattern == 'multi' assert options.dryrun is True assert options.move is True assert files == ['file'] argv = "-c -p internal".split() files = parser.parse(argv) assert options.pattern == 'default-pattern' assert options.dryrun is True # options not changed by argv assert options.move is False # option changed by argv assert files == []
def make_configuration(step): world.conf = configuration.Configuration()
def make_second_configuration(step): world.conf2 = configuration.Configuration()
def setup(): assert os.path.isfile( 'test.cfg'), "Must be run inside tests/, where test.cfg lies" options = configuration.Configuration() options.read('test.cfg') assert options.target_dir == "./bla"
def configuration_from_filename(step, filename): conf = configuration.Configuration() conf.read(filename)
def configuration_should_not_be_altered(step): conf = configuration.Configuration() #world.sth = True assert world.sth == conf.interactive conf.interactive = not world.sth assert conf.interactive is not world.sth
def parser_after_changing_configuration_options(step): conf = configuration.Configuration() conf.interactive = True world.sth = True world.parser = configuration.CmdlineParser()
def configuration_has_defaults(step): conf = configuration.Configuration() assert conf.interactive is False assert conf.pattern == "internal" assert conf.dryrun is True assert conf.verbose is False