Ejemplo n.º 1
0
    def test_build(self):
        """
        Ensure that the build process is working
        """
        # Arrange
        frm = Frame(opCode=0, data=self.data)

        # Act & Assert
        raw = frm.build()
        self.assertIsNotNone(raw, "Unexpected result")
Ejemplo n.º 2
0
    def test_parse(self):
        """
        Ensure the parsing process is working.
        """
        # Arrange
        frm = Frame(opCode=0, data=self.data)
        build = frm.build()

        # Act
        try:
            pos = 0
            neededBytes = next(frm.parser)
            pos = neededBytes
            neededBytes = frm.parser.send(build[0:neededBytes])
            neededBytes = frm.parser.send(build[pos:(pos + neededBytes)])

        except StopIteration:
            data = frm.data

        # Assert
        self.assertEqual(pos, 2, "Start Bytes should be at least two.")
        self.assertEqual(data, self.data, "Parsing went wrong. %s != %s" % (data, self.data))