瀏覽代碼

add tests for CC1101._disable_data_whitening()

Fabian Peter Hammerle 8 月之前
父節點
當前提交
c63e3efb6c
共有 2 個文件被更改,包括 19 次插入1 次删除
  1. 1 1
      .github/workflows/python.yml
  2. 18 0
      tests/config/test_0x08_pktctrl0.py

+ 1 - 1
.github/workflows/python.yml

@@ -57,7 +57,7 @@ jobs:
       env:
         PYTHON_VERSION: ${{ matrix.python-version }}
     - run: pipenv graph
-    - run: pipenv run pytest --cov="$(cat *.egg-info/top_level.txt)" --cov-report=term-missing --cov-fail-under=96
+    - run: pipenv run pytest --cov="$(cat *.egg-info/top_level.txt)" --cov-report=term-missing --cov-fail-under=97
     - run: pipenv run pylint "$(cat *.egg-info/top_level.txt)"
     # https://github.com/PyCQA/pylint/issues/352
     - run: pipenv run pylint tests/*

+ 18 - 0
tests/config/test_0x08_pktctrl0.py

@@ -24,6 +24,24 @@ from cc1101.options import PacketLengthMode
 # pylint: disable=protected-access
 
 
+@pytest.mark.parametrize(
+    ("pktctrl0_before", "pktctrl0_after"),
+    [
+        (0b01000101, 0b00000101),
+        (0b00000101, 0b00000101),
+        (0b11111111, 0b10111111),
+    ],
+)
+def test_disable_data_whitening(transceiver, pktctrl0_before, pktctrl0_after):
+    xfer_mock = transceiver._spi.xfer
+    xfer_mock.return_value = [0xFF] * 2  # chip status byte
+    with unittest.mock.patch.object(
+        transceiver, "_read_single_byte", return_value=pktctrl0_before
+    ):
+        transceiver._disable_data_whitening()
+    xfer_mock.assert_called_once_with([0x08 | 0x40, pktctrl0_after])
+
+
 @pytest.mark.parametrize(
     ("pktctrl0_before", "pktctrl0_after"),
     (