Completed
Branch master (2a692c)
by Felipe A.
55s
created

test_playablefile()   A

Complexity

Conditions 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 9
rs 9.6667
1
import unittest
2
import browsepy
3
4
import browsepy.plugin.player as player
5
import browsepy.plugin.player.playable as player_playable
6
7
class TestPlayerBase(unittest.TestCase):
8
    module = player
9
    app = browsepy.app
10
11
    @classmethod
12
    def setUpClass(cls):
13
        player_module = TestPlayerBase.module
14
        if not player_module.player.name in cls.app.blueprints:
15
            player_module.register_plugin(cls.app.extensions['plugin_manager'])
16
17
18
class TestPlayer(TestPlayerBase):
19
    def test_register_plugin(self):
20
        self.assertIn(self.module.player.name, self.app.blueprints)
21
22
23
class TestPlayable(TestPlayerBase):
24
    module = player_playable
25
26
    def test_playablefile(self):
27
        exts = {
28
         'mp3': 'mp3',
29
         'wav': 'wav',
30
         'ogg': 'ogg'
31
        }
32
        for ext, media_format in exts.items():
33
            pf = self.module.PlayableFile(path = 'asdf.%s' % ext, app=self.app)
34
            self.assertEqual(pf.media_format, media_format)
35
36
    def test_playlistfile(self):
37
        pf = self.module.PlayListFile(path='filename.m3u', app=self.app)
38
        self.assertTrue(isinstance(pf, self.module.M3UFile))
39
        pf = self.module.PlayListFile(path='filename.m3u8', app=self.app)
40
        self.assertTrue(isinstance(pf, self.module.M3UFile))
41
        pf = self.module.PlayListFile(path='filename.pls', app=self.app)
42
        self.assertTrue(isinstance(pf, self.module.PLSFile))
43
44
    def test_m3ufile(self):
45
        pass
46