def test_repoint_xml_windowspath(self): with io.StringIO() as out: parser = xml.sax.make_parser() coords = {'track': 0, 'clip': 0} newname = '130\\09\\slitenewname.wav' repointer = bbxml.BBXMLRepoint(parser, out, coords, newname) repointer.parse(self._xml) out.seek(0) parser2 = xml.sax.make_parser() xmlfilter = bbxml.BBXML(parser) xmlfilter.parse(out) got = xmlfilter.clips() self.assertEqual( { 'level': '420', 'length': '0', 'slicemode': '0', 'quant': '4', 'file': '0', 'slices': ['0', '22016', '44032', '66560'], 'midimode': '0', 'start': '0', 'trigtype': '3', 'loop': '1', 'pitch': '0', 'reverse': '0', 'slize': '1024', 'filename': '130\\09\\slitenewname.wav' }, got[0][0])
def test_overwrite2(self): """Test overwriting clip data from one to another, creating slices""" parser = xml.sax.make_parser() xmlfilter = bbxml.BBXML(parser) xmlfilter.parse(self._xml) clips = xmlfilter.clips() with io.StringIO() as out: coords = {'track': 3, 'clip': 0} newclip = clips[0][0] overwriter = bbxml.BBXMLOverwrite(parser, out, coords, newclip) xml2 = self._make_xmlio() overwriter.parse(xml2) out.seek(0) xmlfilter = bbxml.BBXML(parser) xmlfilter.parse(out) got = xmlfilter.clips() self.assertEqual(clips[0][0], got[3][0])
def test_repoint_xml_unixpath(self): """Unix paths are converted to windows paths""" with io.StringIO() as out: parser = xml.sax.make_parser() coords = {'track': 0, 'clip': 1} newname = '130/09/unixslash.wav' repointer = bbxml.BBXMLRepoint(parser, out, coords, newname) repointer.parse(self._xml) out.seek(0) xmlfilter = bbxml.BBXML(parser) xmlfilter.parse(out) got = xmlfilter.clips() self.assertEqual('130\\09\\unixslash.wav', got[0][1]['filename'])
def test_read_xml(self): parser = xml.sax.make_parser() xmlfilter = bbxml.BBXML(parser) xmlfilter.parse(self._xml) got = xmlfilter.clips() self.assertEqual([{ 'level': '420', 'length': '0', 'slicemode': '0', 'quant': '4', 'file': '0', 'slices': ['0', '22016', '44032', '66560'], 'midimode': '0', 'start': '0', 'trigtype': '3', 'loop': '1', 'pitch': '0', 'reverse': '0', 'slize': '1024', 'filename': '130\\09\\slitekick01.wav' }, { 'level': '400', 'length': '0', 'slicemode': '0', 'quant': '4', 'file': '0', 'slices': ['0', '22016', '44032', '66304'], 'midimode': '0', 'start': '0', 'trigtype': '3', 'loop': '1', 'pitch': '0', 'reverse': '0', 'slize': '1024', 'filename': '130\\09\\sbigkick01.wav' }, { 'level': 0, 'length': 0, 'slicemode': 0, 'quant': 0, 'file': 0, 'slices': [], 'midimode': 0, 'start': 0, 'trigtype': 0, 'loop': 0, 'pitch': 0, 'reverse': 0, 'slize': 0, 'filename': '' }, { 'level': 0, 'length': 0, 'slicemode': 0, 'quant': 0, 'file': 0, 'slices': [], 'midimode': 0, 'start': 0, 'trigtype': 0, 'loop': 0, 'pitch': 0, 'reverse': 0, 'slize': 0, 'filename': '' }], got[0])