コード例 #1
0
    def testLoggingOptions(self):
        import logging
        from eyed3 import log

        with open("/dev/null", "w") as devnull:
            with RedirectStdStreams(stderr=devnull):
                try:
                    _ = main.parseCommandLine(["-l", "critical"])
                    assert_equal(log.getEffectiveLevel(), logging.CRITICAL)

                    _ = main.parseCommandLine(["--log-level=error"])
                    assert_equal(log.getEffectiveLevel(), logging.ERROR)

                    _ = main.parseCommandLine(["-l", "warning:NewLogger"])
                    assert_equal(
                            logging.getLogger("NewLogger").getEffectiveLevel(),
                            logging.WARNING)
                    assert_equal(log.getEffectiveLevel(), logging.ERROR)
                except SystemExit:
                    assert_false("Unexpected")

                try:
                    _ = main.parseCommandLine(["--log-level=INVALID"])
                    assert_false("Invalid log level, an Exception expected")
                except SystemExit:
                    pass
コード例 #2
0
    def testLoadPlugin(self):
        from eyed3 import plugins
        from eyed3.plugins.classic import ClassicPlugin
        from eyed3.plugins.genres import GenreListPlugin

        # XXX: in python3 the import of main is treated differently, in this
        # case it adds confusing isinstance semantics demonstrated below
        # where isinstance works with PY2 and does not in PY3. This is old,
        # long before python3 but it is the closest explanantion I can find.
        #http://mail.python.org/pipermail/python-bugs-list/2004-June/023326.html

        args, _, _ = main.parseCommandLine([""])
        if PY2:
            assert isinstance(args.plugin, ClassicPlugin)
        else:
            assert args.plugin.__class__.__name__ == ClassicPlugin.__name__

        args, _, _ = main.parseCommandLine(["--plugin=genres"])
        if PY2:
            assert isinstance(args.plugin, GenreListPlugin)
        else:
            assert args.plugin.__class__.__name__ == GenreListPlugin.__name__

        with open("/dev/null", "w") as devnull:
            with RedirectStdStreams(stderr=devnull):
                try:
                    args, _ = main.parseCommandLine(["--plugin=DNE"])
                except SystemExit as ex:
                    assert ex.code == 1

                try:
                    args, _, _ = main.parseCommandLine(["--plugin"])
                except SystemExit as ex:
                    assert ex.code == 2
コード例 #3
0
def testPluginOption():
    for arg in ["--help", "-h"]:
        # When help is requested and no plugin is specified, use default
        with RedirectStdStreams() as out:
            try:
                args, _, config = main.parseCommandLine([arg])
            except SystemExit as ex:
                assert_equal(ex.code, 0)
                out.stdout.seek(0)
                sout = out.stdout.read()
                assert_not_equal(sout.find("Plugin options:\n  Classic eyeD3"),
                                 -1)

    # When help is requested and all default plugin names are specified
    for plugin_name in ["classic"]:
        for args in [["--plugin=%s" % plugin_name, "--help"]]:
            with RedirectStdStreams() as out:
                try:
                    args, _, config = main.parseCommandLine(args)
                except SystemExit as ex:
                    assert_equal(ex.code, 0)
                    out.stdout.seek(0)
                    sout = out.stdout.read()
                    assert_not_equal(
                        sout.find("Plugin options:\n  Classic eyeD3"), -1)
コード例 #4
0
    def testLoggingOptions(self):
        import logging
        from eyed3 import log

        with open("/dev/null", "w") as devnull:
            with RedirectStdStreams(stderr=devnull):
                try:
                    _ = main.parseCommandLine(["-l", "critical"])
                    assert log.getEffectiveLevel() == logging.CRITICAL

                    _ = main.parseCommandLine(["--log-level=error"])
                    assert log.getEffectiveLevel() == logging.ERROR

                    _ = main.parseCommandLine(["-l", "warning:NewLogger"])
                    assert (
                        logging.getLogger("NewLogger").getEffectiveLevel() ==
                        logging.WARNING
                    )
                    assert log.getEffectiveLevel() == logging.ERROR
                except SystemExit:
                    assert not("Unexpected")

                try:
                    _ = main.parseCommandLine(["--log-level=INVALID"])
                    assert not("Invalid log level, an Exception expected")
                except SystemExit:
                    pass
コード例 #5
0
    def testLoadPlugin(self):
        from eyed3 import plugins
        from eyed3.plugins.classic import ClassicPlugin
        from eyed3.plugins.genres import GenreListPlugin

        # XXX: in python3 the import of main is treated differently, in this
        # case it adds confusing isinstance semantics demonstrated below
        # where isinstance works with PY2 and does not in PY3. This is old,
        # long before python3 but it is the closest explanantion I can find.
        #http://mail.python.org/pipermail/python-bugs-list/2004-June/023326.html

        args, _, _ = main.parseCommandLine([""])
        if PY2:
            assert_true(isinstance(args.plugin, ClassicPlugin))
        else:
            assert_true(args.plugin.__class__.__name__, ClassicPlugin.__name__)

        args, _, _ = main.parseCommandLine(["--plugin=genres"])
        if PY2:
            assert_true(isinstance(args.plugin, GenreListPlugin))
        else:
            assert_true(args.plugin.__class__.__name__,
                        GenreListPlugin.__name__)

        with open("/dev/null", "w") as devnull:
            with RedirectStdStreams(stderr=devnull):
                try:
                    args, _ = main.parseCommandLine(["--plugin=DNE"])
                except SystemExit as ex:
                    assert_equal(ex.code, 1)

                try:
                    args, _, _ = main.parseCommandLine(["--plugin"])
                except SystemExit as ex:
                    assert_equal(ex.code, 2)
コード例 #6
0
    def testAddRemoveLyrics(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

        comment = "Why can't I be you?"
        for i, (c, d, l) in enumerate([(comment, "c0", None),
                                       (comment, "c1", None),
                                       (comment, "c2", 'eng'),
                                       ("¿Por qué no puedo ser tú ?", "c2",
                                        'esp'),
                                      ]):

            darg = ":{}".format(d) if d else ""
            larg = ":{}".format(l) if l else ""
            opts = ["--add-comment={c}{darg}{larg}".format(**locals()),
                    self.test_file]

            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)

            tag_comment = af.tag.comments.get(d or "",
                                              lang=utils.b(l if l else "eng"))
            assert (tag_comment.text == c)
            assert (tag_comment.description == d or "")
            assert (tag_comment.lang == utils.b(l if l else "eng"))

        for d, l in [("c0", None),
                     ("c1", None),
                     ("c2", "eng"),
                     ("c2", "esp"),
                    ]:

            larg = ":{}".format(l) if l else ""
            opts = ["--remove-comment={d}{larg}".format(**locals()),
                    self.test_file]
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            tag_comment = af.tag.comments.get(d,
                                              lang=utils.b(l if l else "eng"))
            assert tag_comment is None

        assert (len(af.tag.comments) == 0)
コード例 #7
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testAddRemoveLyrics(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

        comment = "Why can't I be you?"
        for i, (c, d, l) in enumerate([(comment, "c0", None),
                                       (comment, "c1", None),
                                       (comment, "c2", 'eng'),
                                       ("¿Por qué no puedo ser tú ?", "c2",
                                        'esp'),
                                      ]):

            darg = ":{}".format(d) if d else ""
            larg = ":{}".format(l) if l else ""
            opts = ["--add-comment={c}{darg}{larg}".format(**locals()),
                    self.test_file]

            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)

            tag_comment = af.tag.comments.get(d or "",
                                              lang=utils.b(l if l else "eng"))
            assert (tag_comment.text == c)
            assert (tag_comment.description == d or "")
            assert (tag_comment.lang == utils.b(l if l else "eng"))

        for d, l in [("c0", None),
                     ("c1", None),
                     ("c2", "eng"),
                     ("c2", "esp"),
                    ]:

            larg = ":{}".format(l) if l else ""
            opts = ["--remove-comment={d}{larg}".format(**locals()),
                    self.test_file]
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            tag_comment = af.tag.comments.get(d,
                                              lang=utils.b(l if l else "eng"))
            assert tag_comment is None

        assert (len(af.tag.comments) == 0)
コード例 #8
0
    def testRemoveAllComments(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

        comment = u"Why can't I be you?"
        for i, (c, d, l) in enumerate([
            (comment, u"c0", None),
            (comment, u"c1", None),
            (comment, u"c2", 'eng'),
            (u"¿Por qué no puedo ser tú ?", u"c2", 'esp'),
            (comment, u"c4", "ger"),
            (comment, u"c4", "rus"),
            (comment, u"c5", "rus"),
        ]):

            darg = u":{}".format(d) if d else ""
            larg = u":{}".format(l) if l else ""
            opts = [
                u"--add-comment={c}{darg}{larg}".format(**locals()),
                self.test_file
            ]

            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert_equal(retval, 0)

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)

            tag_comment = af.tag.comments.get(d or u"",
                                              lang=compat.b(l if l else "eng"))
            assert_equal(tag_comment.text, c)
            assert_equal(tag_comment.description, d or u"")
            assert_equal(tag_comment.lang, compat.b(l if l else "eng"))

        opts = [u"--remove-all-comments", self.test_file]
        self._addVersionOpt(version, opts)

        with RedirectStdStreams() as out:
            args, _, config = main.parseCommandLine(opts)
            retval = main.main(args, config)
            assert_equal(retval, 0)

        af = eyed3.load(self.test_file)
        assert_equal(len(af.tag.comments), 0)
コード例 #9
0
def testLameInfoPlugin():
    test_file = Path(DATA_D) / "mp3_samples/mpeg2.5 12.000kHz __vbr__ simple.mp3"
    with RedirectStdStreams() as plugin_out:
        args, _, config = main.parseCommandLine(["-P", "lameinfo", str(test_file)])
        retval = main.main(args, config)
        assert retval == 0

    stdout = plugin_out.stdout.read()
    assert stdout[stdout.index("Encoder Version"):].strip() == \
"""
Encoder Version     : LAME3.99r
LAME Tag Revision   : 0
VBR Method          : Variable Bitrate method2 (mtrh)
Lowpass Filter      : 6000
Radio Replay Gain   : 12.2 dB (Set automatically)
Encoding Flags      : --nspsytune --nssafejoint
ATH Type            : 5
Bitrate (Minimum)   : 8
Encoder Delay       : 576 samples
Encoder Padding     : 960 samples
Noise Shaping       : 1
Stereo Mode         : Stereo
Unwise Settings     : False
Sample Frequency    : 44.1 kHz
MP3 Gain            : 0 (+0.0 dB)
Preset              : V0
Surround Info       : None
Music Length        : 67.88 KB
Music CRC-16        : 8707
LAME Tag CRC-16     : 0000
""".strip()
コード例 #10
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
def testReadEmptyMp3():
    with RedirectStdStreams() as out:
        args, _, config = main.parseCommandLine([os.path.join(DATA_D,
                                                              "test.mp3")])
        retval = main.main(args, config)
        assert retval == 0
    assert out.stderr.read().find("No ID3 v1.x/v2.x tag found") != -1
コード例 #11
0
def testReadEmptyMp3():
    with RedirectStdStreams() as out:
        args, _, config = main.parseCommandLine(
            [os.path.join(DATA_D, "test.mp3")])
        retval = main.main(args, config)
        assert_equal(retval, 0)
    assert_not_equal(out.stderr.read().find("No ID3 v1.x/v2.x tag found"), -1)
コード例 #12
0
 def testVersionExitsWithSuccess(self):
     with open("/dev/null", "w") as devnull:
         with RedirectStdStreams(stderr=devnull):
             try:
                 args, parser = main.parseCommandLine(["--version"])
             except SystemExit as ex:
                 assert ex.code == 0
コード例 #13
0
 def testVersionExitsWithSuccess(self):
     with open("/dev/null", "w") as devnull:
         with RedirectStdStreams(stderr=devnull):
             try:
                 args, parser = main.parseCommandLine(["--version"])
             except SystemExit as ex:
                 assert_equal(ex.code, 0)
コード例 #14
0
 def func(audiofile, args, expected_retval=0, reload_version=None):
     try:
         args, _, config = main.parseCommandLine(args + [audiofile.path])
         retval = main.main(args, config)
     except SystemExit as sys_exit:
         retval = sys_exit.code
     assert retval == expected_retval
     return eyed3.load(audiofile.path, tag_version=reload_version)
コード例 #15
0
def _eyeD3(audiofile, args, expected_retval=0):
    try:
        args, _, config = main.parseCommandLine(args + [audiofile.path])
        retval = main.main(args, config)
    except SystemExit as exit:
        retval = exit.code
    assert retval == expected_retval
    return eyed3.load(audiofile.path)
コード例 #16
0
 def testHelpExitsSuccess(self):
     with open("/dev/null", "w") as devnull:
         with RedirectStdStreams(stderr=devnull):
             for arg in ["--help", "-h"]:
                 try:
                     args, parser = main.parseCommandLine([arg])
                 except SystemExit as ex:
                     assert ex.code == 0
コード例 #17
0
 def testHelpExitsSuccess(self):
     with open("/dev/null", "w") as devnull:
         with RedirectStdStreams(stderr=devnull):
             for arg in ["--help", "-h"]:
                 try:
                     args, parser = main.parseCommandLine([arg])
                 except SystemExit as ex:
                     assert_equal(ex.code, 0)
コード例 #18
0
 def func(audiofile, args, expected_retval=0, reload_version=None):
     try:
         args, _, config = main.parseCommandLine(args + [audiofile.path])
         retval = main.main(args, config)
     except SystemExit as exit:
         retval = exit.code
     assert retval == expected_retval
     return eyed3.load(audiofile.path, tag_version=reload_version)
コード例 #19
0
    def testUniqueFileId_N(self):
        # Add 3
        with RedirectStdStreams() as out:
            assert out
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:Me",
                                       "--unique-file-id=Engine:Kid",
                                       "--unique-file-id", "Owner:Kid",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 3
        assert af.tag.unique_file_ids.get("Travis").uniq_id == b"Me"
        assert af.tag.unique_file_ids.get("Engine").uniq_id == b"Kid"
        assert af.tag.unique_file_ids.get(b"Owner").uniq_id == b"Kid"

        # Remove 2
        with RedirectStdStreams() as out:
            assert out
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:",
                                       "--unique-file-id=Engine:",
                                       "--unique-file-id", "Owner:Kid",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1

        # Remove not found ID
        with RedirectStdStreams() as out:
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        sout = out.stdout.read()
        assert "Unique file ID 'Travis' not found" in sout

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1
コード例 #20
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testUniqueFileId_N(self):
        # Add 3
        with RedirectStdStreams() as out:
            assert out
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:Me",
                                       "--unique-file-id=Engine:Kid",
                                       "--unique-file-id", "Owner:Kid",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 3
        assert af.tag.unique_file_ids.get("Travis").uniq_id == b"Me"
        assert af.tag.unique_file_ids.get("Engine").uniq_id == b"Kid"
        assert af.tag.unique_file_ids.get(b"Owner").uniq_id == b"Kid"

        # Remove 2
        with RedirectStdStreams() as out:
            assert out
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:",
                                       "--unique-file-id=Engine:",
                                       "--unique-file-id", "Owner:Kid",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1

        # Remove not found ID
        with RedirectStdStreams() as out:
            args, _, config = \
                main.parseCommandLine(["--unique-file-id", "Travis:",
                                       self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        sout = out.stdout.read()
        assert "Unique file ID 'Travis' not found" in sout

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1
コード例 #21
0
def testLameInfoPlugin_None():
    test_file = Path(DATA_D) / "test.mp3"
    with RedirectStdStreams() as plugin_out:
        args, _, config = main.parseCommandLine(["-P", "lameinfo", str(test_file)])
        retval = main.main(args, config)
        assert retval == 0

    stdout = plugin_out.stdout.read()
    assert stdout[stdout.index("--\n") + 3:].strip() == "No LAME Tag"
コード例 #22
0
def _runPlugin(afile, plugin) -> str:
    with RedirectStdStreams() as plugin_out:
        args, _, config = main.parseCommandLine(
            ["-P", plugin, str(afile.path)])
        assert main.main(args, config) == 0

    stdout = plugin_out.stdout.read().strip()
    print(stdout)
    return stdout
コード例 #23
0
 def testHelpOutput(self):
         for arg in ["--help", "-h"]:
             with RedirectStdStreams() as out:
                 try:
                     args, parser = main.parseCommandLine([arg])
                 except SystemExit as ex:
                     # __exit__ seeks and we're not there yet so...
                     out.stdout.seek(0)
                     assert out.stdout.read().startswith(u"usage:")
                     assert ex.code == 0
コード例 #24
0
 def testVersionOutput(self):
         for arg in ["--version"]:
             with RedirectStdStreams(stderr=StringIO()) as out:
                 try:
                     args, parser = main.parseCommandLine([arg])
                 except SystemExit as ex:
                     out.stderr.seek(0)
                     expected = "eyeD3 %s-%s" % (info.VERSION, info.RELEASE)
                     assert_true(out.stderr.read().startswith(expected))
                     assert_equal(ex.code, 0)
コード例 #25
0
 def testHelpOutput(self):
         for arg in ["--help", "-h"]:
             with RedirectStdStreams() as out:
                 try:
                     args, parser = main.parseCommandLine([arg])
                 except SystemExit as ex:
                     # __exit__ seeks and we're not there yet so...
                     out.stdout.seek(0)
                     assert_true(out.stdout.read().startswith(u"usage:"))
                     assert_equal(ex.code, 0)
コード例 #26
0
    def testNewTagTrackNumInvalid(self):
        for opts in [["-n", "abc", self.test_file],
                     ["--track=-14", self.test_file]]:

            with RedirectStdStreams() as out:
                try:
                    args, _, config = main.parseCommandLine(opts)
                except SystemExit as ex:
                    assert_not_equal(ex.code, 0)
                else:
                    assert_false("Should not have gotten here")
コード例 #27
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testUniqueFileId_1(self):
        with RedirectStdStreams() as out:
            assert out
            args, _, config = main.parseCommandLine(["--unique-file-id", "Travis:Me",
                                                     self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1
        assert af.tag.unique_file_ids.get(b"Travis").uniq_id == b"Me"
コード例 #28
0
    def testUniqueFileId_1(self):
        with RedirectStdStreams() as out:
            assert out
            args, _, config = main.parseCommandLine(["--unique-file-id", "Travis:Me",
                                                     self.test_file])
            retval = main.main(args, config)
            assert retval == 0

        af = eyed3.load(self.test_file)
        assert len(af.tag.unique_file_ids) == 1
        assert af.tag.unique_file_ids.get(b"Travis").uniq_id == b"Me"
コード例 #29
0
ファイル: test_main.py プロジェクト: nicfit/eyed3
    def testLoadPlugin(self):
        from eyed3.plugins.classic import ClassicPlugin
        from eyed3.plugins.genres import GenreListPlugin

        args, _, _ = main.parseCommandLine([""])
        assert args.plugin.__class__.__name__ == ClassicPlugin.__name__

        args, _, _ = main.parseCommandLine(["--plugin=genres"])
        assert args.plugin.__class__.__name__ == GenreListPlugin.__name__

        with open("/dev/null", "w") as devnull:
            with RedirectStdStreams(stderr=devnull):
                try:
                    args, _ = main.parseCommandLine(["--plugin=DNE"])
                except SystemExit as ex:
                    assert ex.code == 1

                try:
                    args, _, _ = main.parseCommandLine(["--plugin"])
                except SystemExit as ex:
                    assert ex.code == 2
コード例 #30
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagTrackNumInvalid(self):
        for opts in [ ["-n", "abc", self.test_file],
                      ["--track=-14", self.test_file]
                      ]:

            with RedirectStdStreams() as out:
                try:
                    args, _, config = main.parseCommandLine(opts)
                except SystemExit as ex:
                    assert ex.code != 0
                else:
                    assert not("Should not have gotten here")
コード例 #31
0
ファイル: test_main.py プロジェクト: zhu/eyeD3
    def testLoadPlugin(self):
        from eyed3.plugins.classic import ClassicPlugin
        from eyed3.plugins.genres import GenreListPlugin

        args, _, _ = main.parseCommandLine([""])
        assert args.plugin.__class__.__name__ == ClassicPlugin.__name__

        args, _, _ = main.parseCommandLine(["--plugin=genres"])
        assert args.plugin.__class__.__name__ == GenreListPlugin.__name__

        with open("/dev/null", "w") as devnull:
            with RedirectStdStreams(stderr=devnull):
                try:
                    args, _ = main.parseCommandLine(["--plugin=DNE"])
                except SystemExit as ex:
                    assert ex.code == 1

                try:
                    args, _, _ = main.parseCommandLine(["--plugin"])
                except SystemExit as ex:
                    assert ex.code == 2
コード例 #32
0
    def testNewTagOrigRelease(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["--orig-release-date=1981", self.test_file]]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert_equal(retval, 0)

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.original_release_date.year, 1981)
コード例 #33
0
ファイル: test_classic_plugin.py プロジェクト: jdimpson/eyeD3
    def testNewTagNonStdGenre(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in (("-G", "108", "--non-std-genre", self.test_file),
                     ("--genre=108", "--non-std-genre", self.test_file)):
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert retval == 0

            af = eyed3.load(self.test_file)
            assert af.tag.non_std_genre.name == "108"
            assert af.tag.non_std_genre.id is None
コード例 #34
0
    def testNewTagComposer(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["--composer=H.R.", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert retval == 0

            af = eyed3.load(self.test_file)
            assert  af is not None
            assert  af.tag is not None
            assert af.tag.composer == "H.R."
コード例 #35
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagComposer(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["--composer=H.R.", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert retval == 0

            af = eyed3.load(self.test_file)
            assert  af is not None
            assert  af.tag is not None
            assert af.tag.composer == "H.R."
コード例 #36
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagOrigRelease(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["--orig-release-date=1981", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.original_release_date.year == 1981)
コード例 #37
0
    def testNewTagAlbumArtist(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-b", "Various Artists", self.test_file],
                      ["--album-artist=Various Artists", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert af is not None
            assert af.tag is not None
            assert af.tag.album_artist == "Various Artists"
コード例 #38
0
    def testNewTagAlbumArtist(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-b", "Various Artists", self.test_file],
                      ["--album-artist=Various Artists", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert af is not None
            assert af.tag is not None
            assert af.tag.album_artist == u"Various Artists"
コード例 #39
0
    def testNewTagTitle(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["-t", "Green Door", self.test_file],
                     ["--title=Green Door", self.test_file]]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert_equal(retval, 0)

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.title, u"Green Door")
コード例 #40
0
 def testVersionOutput(self):
     for arg in ["--version"]:
         with RedirectStdStreams() as out:
             try:
                 args, parser = main.parseCommandLine([arg])
             except SystemExit as ex:
                 # Apparently argparse changed --version output stream
                 stream = out.stdout if sys.version_info[0:2] >= (3, 4)\
                                     else out.stderr
                 stream.seek(0)
                 expected = "eyeD3 %s-%s" % (".".join(
                     [str(d) for d in info.VERSION_TUPLE]), info.RELEASE)
                 assert_true(stream.read().startswith(expected))
                 assert_equal(ex.code, 0)
コード例 #41
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagArtist(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-a", "The Cramps", self.test_file],
                      ["--artist=The Cramps", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert retval == 0

            af = eyed3.load(self.test_file)
            assert  af is not None
            assert  af.tag is not None
            assert af.tag.artist == "The Cramps"
コード例 #42
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagTitle(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-t", "Green Door", self.test_file],
                      ["--title=Green Door", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.title == "Green Door")
コード例 #43
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagTrackNum(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-n", "14", self.test_file],
                      ["--track=14", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.track_num[0] == 14)
コード例 #44
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagAlbum(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-A", "Psychedelic Jungle", self.test_file],
                      ["--album=Psychedelic Jungle", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.album == "Psychedelic Jungle")
コード例 #45
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
def testPluginOption():
    for arg in ["--help", "-h"]:
        # When help is requested and no plugin is specified, use default
        with RedirectStdStreams() as out:
            try:
                args, _, config = main.parseCommandLine([arg])
            except SystemExit as ex:
                assert ex.code == 0
                out.stdout.seek(0)
                sout = out.stdout.read()
                assert sout.find("Plugin options:\n  Classic eyeD3") != -1

    # When help is requested and all default plugin names are specified
    for plugin_name in ["classic"]:
        for args in [["--plugin=%s" % plugin_name, "--help"]]:
            with RedirectStdStreams() as out:
                try:
                    args, _, config = main.parseCommandLine(args)
                except SystemExit as ex:
                    assert ex.code == 0
                    out.stdout.seek(0)
                    sout = out.stdout.read()
                    assert sout.find("Plugin options:\n  Classic eyeD3") != -1
コード例 #46
0
    def testNewTagArtist(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["-a", "The Cramps", self.test_file],
                     ["--artist=The Cramps", self.test_file]]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert_equal(retval, 0)

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.artist, u"The Cramps")
コード例 #47
0
    def testNewTagAlbum(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["-A", "Psychedelic Jungle", self.test_file],
                     ["--album=Psychedelic Jungle", self.test_file]]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert_equal(retval, 0)

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.album, u"Psychedelic Jungle")
コード例 #48
0
    def testNewTagTrackNum(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["-n", "14", self.test_file],
                     ["--track=14", self.test_file]]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert_equal(retval, 0)

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.track_num[0], 14)
コード例 #49
0
    def testNewTagRecordingDate(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [["--recording-date=1993-10-30", self.test_file]]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert_equal(retval, 0)

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.recording_date.year, 1993)
            assert_equal(af.tag.recording_date.month, 10)
            assert_equal(af.tag.recording_date.day, 30)
コード例 #50
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagGenre(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["-G", "Rock", self.test_file],
                      ["--genre=Rock", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.genre.name == "Rock")
            assert (af.tag.genre.id == 17)
コード例 #51
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagRecordingDate(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["--recording-date=1993-10-30", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.recording_date.year == 1993)
            assert (af.tag.recording_date.month == 10)
            assert (af.tag.recording_date.day == 30)
コード例 #52
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagPublisher(self):
        for expected, opts in [
                ("SST", ["--publisher", "SST", self.test_file]),
                ("Dischord", ["--publisher=Dischord", self.test_file]),
               ]:

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.publisher == expected)
コード例 #53
0
    def testNewTagPublisher(self):
        for expected, opts in [
            ("SST", ["--publisher", "SST", self.test_file]),
            ("Dischord", ["--publisher=Dischord", self.test_file]),
        ]:

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert_equal(retval, 0)

            af = eyed3.load(self.test_file)
            assert_is_not_none(af)
            assert_is_not_none(af.tag)
            assert_equal(af.tag.publisher, expected)
コード例 #54
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagBpmInvalid(self):
        for expected, opts in [ (0, ["--bpm=", self.test_file]),
                                (0, ["--bpm=-24", self.test_file]),
                                (0, ["--bpm=+", self.test_file]),
                                (0, ["--bpm=abc", self.test_file]),
                                (0, ["--bpm", "=180", self.test_file]),
                              ]:

            with RedirectStdStreams() as out:
                try:
                    args, _, config = main.parseCommandLine(opts)
                except SystemExit as ex:
                    assert ex.code != 0
                else:
                    assert not("Should not have gotten here")
コード例 #55
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagReleaseDate(self, version=id3.ID3_DEFAULT_VERSION):
        for date in ["1981", "1981-03-06", "1981-03"]:
            orig_date = core.Date.parse(date)

            for opts in [ ["--release-date=%s" % str(date), self.test_file] ]:
                self._addVersionOpt(version, opts)

                with RedirectStdStreams() as out:
                    args, _, config = main.parseCommandLine(opts)
                    retval = main.main(args, config)
                    assert (retval == 0)

                af = eyed3.load(self.test_file)
                assert (af is not None)
                assert (af.tag is not None)
                assert (af.tag.release_date == orig_date)
コード例 #56
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagBpm(self):
        for expected, opts in [ (1, ["--bpm=1", self.test_file]),
                                (180, ["--bpm=180", self.test_file]),
                                (117, ["--bpm", "116.7", self.test_file]),
                                (116, ["--bpm", "116.4", self.test_file]),
                              ]:

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.bpm == expected)
コード例 #57
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagTaggingDate(self, version=id3.ID3_DEFAULT_VERSION):
        for opts in [ ["--tagging-date=2012-10-23T20:22", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.tagging_date.year == 2012)
            assert (af.tag.tagging_date.month == 10)
            assert (af.tag.tagging_date.day == 23)
            assert (af.tag.tagging_date.hour == 20)
            assert (af.tag.tagging_date.minute == 22)
コード例 #58
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagPlayCount(self):
        for expected, opts in [ (0, ["--play-count=0", self.test_file]),
                                (1, ["--play-count=+1", self.test_file]),
                                (6, ["--play-count=+5", self.test_file]),
                                (7, ["--play-count=7", self.test_file]),
                                (10000, ["--play-count=10000", self.test_file]),
                              ]:

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.play_count == expected)
コード例 #59
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagTrackTotal(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

        for opts in [ ["-N", "14", self.test_file],
                      ["--track-total=14", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.track_num[1] == 14)
コード例 #60
0
ファイル: test_classic_plugin.py プロジェクト: nicfit/eyed3
    def testNewTagSimpleComment(self, version=id3.ID3_DEFAULT_VERSION):
        if version[0] == 1:
            # No support for this in v1.x
            return

        for opts in [ ["-c", "Starlette", self.test_file],
                      ["--comment=Starlette", self.test_file] ]:
            self._addVersionOpt(version, opts)

            with RedirectStdStreams() as out:
                args, _, config = main.parseCommandLine(opts)
                retval = main.main(args, config)
                assert (retval == 0)

            af = eyed3.load(self.test_file)
            assert (af is not None)
            assert (af.tag is not None)
            assert (af.tag.comments[0].text == "Starlette")
            assert (af.tag.comments[0].description == "")