コード例 #1
0
    def test_write_id3(self):
        """ Test write id3 tags """
        sandbox = os.path.dirname(os.path.realpath(__file__)) + "/sandbox/"
        sample = os.path.dirname(os.path.realpath(__file__)) + "/samples/"
        filename = "92583301-dem-beats-3.mp3"

        if not os.path.exists(sandbox):
            os.mkdir(sandbox)
        shutil.copyfile(sample + filename, sandbox + filename)

        tag = stag()
        tag._process_artwork_tmpfile = Mock(return_value=False)
        client = Mock()
        track = strack(json_obj[0], client=client)
        tag.load_id3(track)

        tag.write_id3(sandbox + filename)

        res = stagger.read_tag(sandbox + filename)
        self.assertEqual("Some text", res[TIT1].text[0])
        self.assertEqual("Foo", res[TIT2].text[0])
        self.assertEqual("dubstep bass", res[TIT3].text[0])
        self.assertEqual("247010", res[TLEN].text[0])
        self.assertEqual("foo", res[TOFN].text[0])
        self.assertEqual("Dubstep", res[TCON].text[0])
        self.assertEqual("free", res[TCOP].text[0])
        self.assertEqual("1387373820", res[TDOR].text[0])
        self.assertEqual("https://foobar.dev/1337", res[WOAS].url)
        self.assertEqual("https://api.foobar.dev/1337", res[WOAF].url)
        self.assertEqual("user1", res[TPUB].text[0])
        self.assertEqual("http://user1.dev", res[WOAR][0].url)
        self.assertEqual("User 1", res[TPE1].text[0])
        self.assertEqual("User 1 Soundcloud tracks", res[TALB].text[0])

        shutil.rmtree(sandbox)
コード例 #2
0
    def test_write_id3(self):
        """ Test write id3 tags """
        sandbox = os.path.dirname(os.path.realpath(__file__)) + "/sandbox/"
        sample = os.path.dirname(os.path.realpath(__file__)) + "/samples/"
        filename = "92583301-dem-beats-3.mp3"

        if not os.path.exists(sandbox):
            os.mkdir(sandbox)
        shutil.copyfile(sample + filename, sandbox + filename)

        tag = stag()
        tag._process_artwork_tmpfile = Mock(return_value=False)
        client = Mock()
        track = strack(json_obj[0], client=client)
        tag.load_id3(track)

        tag.write_id3(sandbox + filename)

        res = stagger.read_tag(sandbox + filename)
        self.assertEqual("Some text", res[TIT1].text[0])
        self.assertEqual("Foo", res[TIT2].text[0])
        self.assertEqual("dubstep bass", res[TIT3].text[0])
        self.assertEqual("247010", res[TLEN].text[0])
        self.assertEqual("foo", res[TOFN].text[0])
        self.assertEqual("Dubstep", res[TCON].text[0])
        self.assertEqual("free", res[TCOP].text[0])
        self.assertEqual("1387373820", res[TDOR].text[0])
        self.assertEqual("https://foobar.dev/1337", res[WOAS].url)
        self.assertEqual("https://api.foobar.dev/1337", res[WOAF].url)
        self.assertEqual("user1", res[TPUB].text[0])
        self.assertEqual("http://user1.dev", res[WOAR][0].url)
        self.assertEqual("User 1", res[TPE1].text[0])
        self.assertEqual("User 1 Soundcloud tracks", res[TALB].text[0])

        shutil.rmtree(sandbox)
コード例 #3
0
    def test_load_id3(self):
        """ Test load id3 tags """
        tag = stag()
        tag._process_artwork_tmpfile = Mock(return_value=False)
        client = Mock()
        track = strack(json_obj[0], client=client)

        tag.load_id3(track)

        self.assertEqual("Some text", tag.mapper._frames["TIT1"][0].text[0])
        self.assertEqual("Foo", tag.mapper._frames["TIT2"][0].text[0])
        self.assertEqual("dubstep bass", tag.mapper._frames["TIT3"][0].text[0])
        self.assertEqual("1387373820", tag.mapper._frames["TDOR"][0].text[0])
        self.assertEqual("247010", tag.mapper._frames["TLEN"][0].text[0])
        self.assertEqual("foo", tag.mapper._frames["TOFN"][0].text[0])
        self.assertEqual("Dubstep", tag.mapper._frames["TCON"][0].text[0])
        self.assertEqual("free", tag.mapper._frames["TCOP"][0].text[0])
        self.assertEqual("https://foobar.dev/1337",
                         tag.mapper._frames["WOAS"][0].url)
        self.assertEqual("https://api.foobar.dev/1337",
                         tag.mapper._frames["WOAF"][0].url)
        self.assertEqual("user1", tag.mapper._frames["TPUB"][0].text[0])
        self.assertEqual("http://user1.dev",
                         tag.mapper._frames["WOAR"][0].url)
        self.assertEqual("User 1", tag.mapper._frames["TPE1"][0].text[0])
        self.assertEqual("User 1 Soundcloud tracks",
                         tag.mapper._frames["TALB"][0].text[0])
コード例 #4
0
    def test_load_id3(self):
        """ Test load id3 tags """
        tag = stag()
        tag._process_artwork_tmpfile = Mock(return_value=False)
        client = Mock()
        track = strack(json_obj[0], client=client)

        tag.load_id3(track)

        self.assertEqual("Some text", tag.mapper._frames["TIT1"][0].text[0])
        self.assertEqual("Foo", tag.mapper._frames["TIT2"][0].text[0])
        self.assertEqual("dubstep bass", tag.mapper._frames["TIT3"][0].text[0])
        self.assertEqual("1387373820", tag.mapper._frames["TDOR"][0].text[0])
        self.assertEqual("247010", tag.mapper._frames["TLEN"][0].text[0])
        self.assertEqual("foo", tag.mapper._frames["TOFN"][0].text[0])
        self.assertEqual("Dubstep", tag.mapper._frames["TCON"][0].text[0])
        self.assertEqual("free", tag.mapper._frames["TCOP"][0].text[0])
        self.assertEqual("https://foobar.dev/1337",
                         tag.mapper._frames["WOAS"][0].url)
        self.assertEqual("https://api.foobar.dev/1337",
                         tag.mapper._frames["WOAF"][0].url)
        self.assertEqual("user1", tag.mapper._frames["TPUB"][0].text[0])
        self.assertEqual("http://user1.dev", tag.mapper._frames["WOAR"][0].url)
        self.assertEqual("User 1", tag.mapper._frames["TPE1"][0].text[0])
        self.assertEqual("User 1 Soundcloud tracks",
                         tag.mapper._frames["TALB"][0].text[0])
コード例 #5
0
    def test_load_id3_with_different_date_format(self):
        """
        Test load id3 tags with different date format
        Returned date from soundcloud depends of timezone.
        """
        tag = stag()
        tag._process_artwork_tmpfile = Mock(return_value=False)
        client = Mock()

        from copy import copy
        json_track = copy(json_obj[0])
        json_track["created_at"] = "2013-12-18T13:37:00Z"
        track = strack(json_track, client=client)

        tag.load_id3(track)
        self.assertEqual("1387373820", tag.mapper._frames["TDOR"][0].text[0])
コード例 #6
0
    def test_load_id3_with_different_date_format(self):
        """
        Test load id3 tags with different date format
        Returned date from soundcloud depends of timezone.
        """
        tag = stag()
        tag._process_artwork_tmpfile = Mock(return_value=False)
        client = Mock()

        from copy import copy
        json_track = copy(json_obj[0])
        json_track["created_at"] = "2013-12-18T13:37:00Z"
        track = strack(json_track, client=client)

        tag.load_id3(track)
        self.assertEqual("1387373820", tag.mapper._frames["TDOR"][0].text[0])
コード例 #7
0
 def test_load_id3_requires_strack_obj(self):
     """ Test load_id3 raise exception when strack is invalid object """
     tag = stag()
     track = Mock()
     self.assertRaises(TypeError, tag.load_id3, track)
コード例 #8
0
 def test_init_object(self):
     """ Test init stag object"""
     tag = stag()
     from stagger.tags import Tag24
     self.assertIsInstance(tag.mapper, Tag24)
コード例 #9
0
 def test_load_id3_requires_strack_obj(self):
     """ Test load_id3 raise exception when strack is invalid object """
     tag = stag()
     track = Mock()
     self.assertRaises(TypeError, tag.load_id3, track)
コード例 #10
0
 def test_init_object(self):
     """ Test init stag object"""
     tag = stag()
     from stagger.tags import Tag24
     self.assertIsInstance(tag.mapper, Tag24)