diff options
Diffstat (limited to 'utilities')
-rw-r--r-- | utilities/blinkenrocket.py | 12 | ||||
-rw-r--r-- | utilities/test_blinkenrocket.py | 16 |
2 files changed, 25 insertions, 3 deletions
diff --git a/utilities/blinkenrocket.py b/utilities/blinkenrocket.py index 545d25f..30f90ab 100644 --- a/utilities/blinkenrocket.py +++ b/utilities/blinkenrocket.py @@ -134,7 +134,10 @@ class textFrame(Frame): return [chr(self.speed << 4 | self.delay), chr(self.direction << 4 | 0x00)] def getRepresentation(self): - return self.getHeader().append(list(self.text)) + retval = [] + retval.extend(self.getHeader()) + retval.extend(list(self.text)) + return retval class animationFrame(Frame): animation = [] @@ -163,7 +166,10 @@ class animationFrame(Frame): return [chr(self.speed), chr(self.delay)] def getRepresentation(self): - return self.getHeader().extend(self.animation) + retval = [] + retval.extend(self.getHeader()) + retval.extend(self.animation) + return retval class blinkenrocket(): @@ -180,7 +186,7 @@ class blinkenrocket(): if not isinstance(frame, Frame): raise RuntimeError("Incorrect frame supplied") else: - frames.append(frame) + self.frames.append(frame) def getMessage(self): output = [self.startcode, self.startcode] diff --git a/utilities/test_blinkenrocket.py b/utilities/test_blinkenrocket.py index 27d213d..11d8d91 100644 --- a/utilities/test_blinkenrocket.py +++ b/utilities/test_blinkenrocket.py @@ -96,5 +96,21 @@ class TestText(unittest.TestCase): text = textFrame([],speed=7,delay=8,direction=1) self.assertEquals(text.getHeader(),[chr(7 << 4 | 8),chr(1 << 4 | 0)]) +class TestBlinkenrocket(unittest.TestCase): + + def test_addFrameFail(self): + br = blinkenrocket() + with self.assertRaises(Exception): + br.addFrame([]) + + def test_addFrameText(self): + text = textFrame("MUZY",speed=7,delay=8,direction=1) + self.assertEquals(text.getHeader(),[chr(7 << 4 | 8),chr(1 << 4 | 0)]) + self.assertEquals(text.getRepresentation(),[chr(7 << 4 | 8),chr(1 << 4 | 0),'M','U','Z','Y']) + br = blinkenrocket() + br.addFrame(text) + expect = [chr(0x99),chr(0x99),chr(0xA9),chr(0xA9),chr(7 << 4 | 8),chr(1 << 4 | 0),'M','U','Z','Y'] + self.assertEquals(br.getMessage(),expect) + if __name__ == '__main__': unittest.main()
\ No newline at end of file |