Browse Source

test get/set_symbol_rate_baud

Fabian Peter Hammerle 3 years ago
parent
commit
984e49c0fc
2 changed files with 27 additions and 1 deletions
  1. 1 1
      .github/workflows/python.yml
  2. 26 0
      tests/test_config.py

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

@@ -50,7 +50,7 @@ jobs:
       env:
         PYTHON_VERSION: ${{ matrix.python-version }}
     - run: pipenv graph
-    - run: pipenv run pytest --cov=cc1101 --cov-report=term-missing --cov-fail-under=92
+    - run: pipenv run pytest --cov=cc1101 --cov-report=term-missing --cov-fail-under=93
     - run: pipenv run pylint --load-plugins=pylint_import_requirements cc1101
     # https://github.com/PyCQA/pylint/issues/352
     - run: pipenv run pylint tests/*

+ 26 - 0
tests/test_config.py

@@ -105,6 +105,32 @@ def test__symbol_rate_real_to_floating_point(mantissa, exponent, real):
     )
 
 
+@pytest.mark.parametrize(
+    ("mantissa", "exponent", "real"), _SYMBOL_RATE_MANTISSA_EXPONENT_REAL_PARAMS
+)
+def test_get_symbol_rate_baud(transceiver, mantissa, exponent, real):
+    with unittest.mock.patch.object(
+        transceiver, "_get_symbol_rate_mantissa", return_value=mantissa
+    ), unittest.mock.patch.object(
+        transceiver, "_get_symbol_rate_exponent", return_value=exponent
+    ):
+        assert transceiver.get_symbol_rate_baud() == pytest.approx(real, rel=1e-5)
+
+
+@pytest.mark.parametrize(
+    ("mantissa", "exponent", "real"), _SYMBOL_RATE_MANTISSA_EXPONENT_REAL_PARAMS
+)
+def test_set_symbol_rate_baud(transceiver, mantissa, exponent, real):
+    with unittest.mock.patch.object(
+        transceiver, "_set_symbol_rate_mantissa"
+    ) as set_mantissa_mock, unittest.mock.patch.object(
+        transceiver, "_set_symbol_rate_exponent"
+    ) as set_exponent_mock:
+        transceiver.set_symbol_rate_baud(real)
+    set_mantissa_mock.assert_called_once_with(mantissa)
+    set_exponent_mock.assert_called_once_with(exponent)
+
+
 @pytest.mark.parametrize(
     ("freq_hz", "warn"),
     (