1# -*- coding: utf-8 -*- 2 3import os 4 5from mutagen._compat import text_type 6from mutagen._senf import fsnative as fsn 7 8from tests.test_tools import _TTools 9from tests import DATA_DIR, get_temp_copy 10 11 12class TMOggSPlit(_TTools): 13 14 TOOL_NAME = u"moggsplit" 15 16 def setUp(self): 17 super(TMOggSPlit, self).setUp() 18 self.filename = get_temp_copy( 19 os.path.join(DATA_DIR, fsn(u'multipagecomment.ogg'))) 20 21 # append the second file 22 with open(self.filename, "ab") as first: 23 to_append = os.path.join( 24 DATA_DIR, fsn(u'multipage-setup.ogg')) 25 with open(to_append, "rb") as second: 26 first.write(second.read()) 27 28 def tearDown(self): 29 super(TMOggSPlit, self).tearDown() 30 os.unlink(self.filename) 31 32 def test_basic(self): 33 d = os.path.dirname(self.filename) 34 p = os.path.join(d, fsn(u"%(stream)d.%(ext)s")) 35 res, out = self.call(fsn(u"--pattern"), p, self.filename) 36 self.failIf(res) 37 self.failIf(out) 38 39 for stream in [1002429366, 1806412655]: 40 stream_path = os.path.join( 41 d, fsn(text_type(stream)) + fsn(u".ogg")) 42 self.failUnless(os.path.exists(stream_path)) 43 os.unlink(stream_path) 44