nanovna-saver/tests/test_sweep.py

50 wiersze
2.0 KiB
Python
Czysty Zwykły widok Historia

2020-07-25 19:34:49 +00:00
# NanoVNASaver
#
# A python program to view and export Touchstone data from a NanoVNA
# Copyright (C) 2019, 2020 Rune B. Broberg
2021-06-30 05:21:14 +00:00
# Copyright (C) 2020,2021 NanoVNA-Saver Authors
2020-07-25 19:34:49 +00:00
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import unittest
# Import targets to be tested
2020-07-27 15:06:46 +00:00
from NanoVNASaver.Settings.Sweep import Sweep, Properties
2020-07-25 19:34:49 +00:00
2022-05-27 07:03:37 +00:00
2020-07-25 19:34:49 +00:00
class TestCases(unittest.TestCase):
def test_sweep(self):
sweep = Sweep()
2020-07-27 15:06:46 +00:00
self.assertEqual(str(sweep),
"Sweep(start=3600000, end=30000000, points=101,"
" segments=1, properties=Properties(name='',"
" mode=<SweepMode.SINGLE: 0>, averages=(3, 0),"
" logarithmic=False))")
2020-07-25 19:34:49 +00:00
self.assertTrue(Sweep(3600000) == sweep)
self.assertFalse(Sweep(3600001) == sweep)
self.assertRaises(ValueError, Sweep, -1)
2020-07-27 15:06:46 +00:00
sweep = Sweep(segments=3)
self.assertEqual(sweep.get_index_range(1), (12429117, 21170817))
2020-07-25 19:34:49 +00:00
data = list(sweep.get_frequencies())
self.assertEqual(data[0], 3600000)
self.assertEqual(data[-1], 29913383)
2020-07-27 15:06:46 +00:00
sweep = Sweep(segments=3, properties=Properties(logarithmic=True))
2020-07-25 19:34:49 +00:00
self.assertEqual(sweep.get_index_range(1), (9078495, 16800000))
data = list(sweep.get_frequencies())
self.assertEqual(data[0], 3600000)
self.assertEqual(data[-1], 29869307)
2020-07-28 15:07:53 +00:00
sweep2 = sweep.copy()
self.assertEqual(sweep, sweep2)