def test_bundle_constructor(self):

        bundle = osc.OSCBundle(
            messages=[osc.OSCMessage('/param'),
                      osc.OSCMessage('/param2')])

        self.assertEqual(2, bundle.length)
    def test_build_complex_bundle(self):

        bundle = osc.OSCBundle(timestamp=osc.IMMEDIATELY)
        msg = osc.OSCMessage(address="/SYNC")
        msg.add(4.0)
        # Add 4 messages in the bundle, each with more arguments.
        bundle.add(msg)
        msg.add(2)
        bundle.add(msg)
        msg.add("value")
        bundle.add(msg)
        msg.add(b"\x01\x02\x03")
        bundle.add(msg)

        sub_bundle = bundle
        # Now add the same bundle inside itself.
        bundle.add(sub_bundle)
        bundle = bundle.build()

        self.assertEqual(5, bundle.length)
    def test_raises_on_build(self):

        bundle = osc.OSCBundle(timestamp=0.0)

        self.assertRaises(osc.OSCBuildError, bundle.add, None)
    def test_raises_on_invalid_timestamp(self):

        bundle = osc.OSCBundle(timestamp="I am not a timestamp")

        self.assertRaises(osc.OSCBuildError, bundle.build)
    def test_empty_bundle(self):

        bundle = osc.OSCBundle(timestamp=osc.IMMEDIATELY).build()

        self.assertEqual(0, bundle.length)