Skip to content

Commit

Permalink
fix dict type hints and update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dboulware committed Jan 14, 2024
1 parent 946a14a commit 8410505
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions scos_actions/calibration/tests/test_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def setup_calibration_file(self, tmpdir):
json.dump(cal_data, file, indent=4)

# Load the data back in
self.sample_cal = load_from_json(self.calibration_file)
self.sample_cal = load_from_json(self.calibration_file, False)

# Create a list of previous points to ensure that we don't repeat
self.pytest_points = []
Expand Down Expand Up @@ -234,6 +234,7 @@ def test_get_calibration_dict_exact_match_lookup(self):
calibration_params,
calibration_data,
clock_rate_lookup_by_sample_rate,
False,
)
cal_data = cal.get_calibration_dict([100.0, 200.0])
assert cal_data["NF"] == "NF at 100, 200"
Expand All @@ -251,6 +252,7 @@ def test_get_calibration_dict_within_range(self):
calibration_params,
calibration_data,
clock_rate_lookup_by_sample_rate,
False,
)
with pytest.raises(CalibrationException) as e_info:
cal_data = cal.get_calibration_dict([100.0, 250.0])
Expand Down Expand Up @@ -290,12 +292,13 @@ def test_update(self):
calibration_params,
calibration_data,
clock_rate_lookup_by_sample_rate,
False,
)
action_params = {"sample_rate": 100.0, "frequency": 200.0}
update_time = get_datetime_str_now()
test_cal_path = Path("test_calibration.json")
cal.update(action_params, update_time, 30.0, 5.0, 21, test_cal_path)
cal_from_file = load_from_json(test_cal_path)
cal_from_file = load_from_json(test_cal_path, False)
test_cal_path.unlink()
file_utc_time = parse_datetime_iso_format_str(cal.last_calibration_datetime)
cal_time_utc = parse_datetime_iso_format_str(update_time)
Expand Down
7 changes: 4 additions & 3 deletions scos_actions/hardware/sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import hashlib
from typing import Dict

from its_preselector.preselector import Preselector
from its_preselector.web_relay import WebRelay
Expand All @@ -15,7 +16,7 @@ def __init__(
signal_analyzer: SignalAnalyzerInterface = MockSignalAnalyzer,
gps: GPSInterface = MockGPS(),
preselector: Preselector = None,
switches: dict[str, WebRelay] = {},
switches: Dict[str, WebRelay] = {},
location: dict = None,
capabilities: dict = None,
):
Expand Down Expand Up @@ -51,11 +52,11 @@ def preselector(self, preselector: Preselector):
self._preselector = preselector

@property
def switches(self) -> dict[str, WebRelay]:
def switches(self) -> Dict[str, WebRelay]:
return self._switches

@switches.setter
def switches(self, switches: dict[str, WebRelay]):
def switches(self, switches: Dict[str, WebRelay]):
self._switches = switches

@property
Expand Down

0 comments on commit 8410505

Please sign in to comment.