File: frame_error_test.py

package info (click to toggle)
pyvlx 0.2.32-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,616 kB
  • sloc: python: 9,114; makefile: 53; sh: 5
file content (28 lines) | stat: -rw-r--r-- 1,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Unit tests for FrameErrorNotification."""
import unittest

from pyvlx.api.frame_creation import frame_from_raw
from pyvlx.api.frames import ErrorType, FrameErrorNotification


class TestErrorNotification(unittest.TestCase):
    """Test class for FrameErrorNotification."""

    def test_bytes(self) -> None:
        """Test FrameErrorNotification with Light."""
        frame = FrameErrorNotification(error_type=ErrorType.ErrorOnFrameStructure)
        self.assertEqual(bytes(frame), b"\x00\x04\x00\x00\x02\x06")

    def test_frame_from_raw(self) -> None:
        """Test parse FrameErrorNotification from raw."""
        frame = frame_from_raw(b"\x00\x04\x00\x00\x02\x06")
        self.assertTrue(isinstance(frame, FrameErrorNotification))
        self.assertEqual(frame.error_type, ErrorType.ErrorOnFrameStructure)

    def test_str(self) -> None:
        """Test string representation of FrameErrorNotification."""
        frame = FrameErrorNotification(error_type=ErrorType.ErrorOnFrameStructure)
        self.assertEqual(
            str(frame),
            '<FrameErrorNotification error_type="ErrorType.ErrorOnFrameStructure"/>',
        )