def testReadBadCount(self): handle = StringIO("""BEAT_START COUNT |^e+d| BEAT_END""") iterator = fileUtils.dbFileIterator(handle) self.assertRaises(DBErrors.BadCount, dbfsv1.BeatStructureV1().read, iterator)
def testReadBadTicks(self): handle = StringIO("""BEAT_START NUM_TICKS x COUNT |^e+a| BEAT_END""") iterator = fileUtils.dbFileIterator(handle) self.assertRaises(DBErrors.InvalidInteger, dbfsv1.BeatStructureV1().read, iterator)
def testReadPartial(self): handle = StringIO("""BEAT_START NUM_TICKS 2 COUNT |^e+a| BEAT_END""") iterator = fileUtils.dbFileIterator(handle) beat = dbfsv1.BeatStructureV1().read(iterator) self.assertEqual("".join(beat.count(1)), "1e")
def testReadBadLine(self): handle = StringIO("""BEAT_START NUM_TICKS 4 COUNT |^e+a| BAD_LINE xxx BEAT_END""") iterator = fileUtils.dbFileIterator(handle) self.assertRaises(DBErrors.UnrecognisedLine, dbfsv1.BeatStructureV1().read, iterator)
def testWritePartialBeat(self): beat = Beat.Beat(Counter.Counter("e+a"), 2) handle = StringIO() indenter = fileUtils.Indenter(handle) dbfsv1.BeatStructureV1().write(beat, indenter) output = handle.getvalue().splitlines() self.assertEqual(output, ["BEAT_START", " NUM_TICKS 2", " COUNT |^e+a|", "BEAT_END"])