File: dimmable_device_test.py

package info (click to toggle)
pyvlx 0.2.30-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,556 kB
  • sloc: python: 8,100; makefile: 38; sh: 5
file content (50 lines) | stat: -rw-r--r-- 1,707 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Unit test for lights."""
import unittest
from unittest.mock import MagicMock

from pyvlx import Light, PyVLX
from pyvlx.connection import Connection


# pylint: disable=too-many-public-methods,invalid-name
class TestDimmableDevice(unittest.TestCase):
    """Test class for lights."""

    def setUp(self) -> None:
        """Set up TestDimmableDevice."""
        self.pyvlx = MagicMock(spec=PyVLX)
        connection = MagicMock(spec=Connection)
        self.pyvlx.attach_mock(mock=connection, attribute="connection")

    def test_light_str(self) -> None:
        """Test string representation of Light object."""
        light = Light(
            pyvlx=self.pyvlx,
            node_id=23,
            name="Test Light",
            serial_number="aa:bb:aa:bb:aa:bb:aa:23",
        )
        self.assertEqual(
            str(light),
            '<Light name="Test Light" node_id="23" serial_number="aa:bb:aa:bb:aa:bb:aa:23"/>',
        )

    def test_eq(self) -> None:
        """Testing eq method with positive results."""
        node1 = Light(
            pyvlx=self.pyvlx, node_id=23, name="xxx", serial_number="aa:bb:aa:bb:aa:bb:aa:23"
        )
        node2 = Light(
            pyvlx=self.pyvlx, node_id=23, name="xxx", serial_number="aa:bb:aa:bb:aa:bb:aa:23"
        )
        self.assertEqual(node1, node2)

    def test_nq(self) -> None:
        """Testing eq method with negative results."""
        node1 = Light(
            pyvlx=self.pyvlx, node_id=23, name="xxx", serial_number="aa:bb:aa:bb:aa:bb:aa:23"
        )
        node2 = Light(
            pyvlx=self.pyvlx, node_id=24, name="xxx", serial_number="aa:bb:aa:bb:aa:bb:aa:23"
        )
        self.assertNotEqual(node1, node2)