shepherd-core 2023.12.1__py3-none-any.whl → 2024.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. shepherd_core/__init__.py +3 -2
  2. shepherd_core/data_models/base/calibration.py +3 -1
  3. shepherd_core/data_models/base/content.py +11 -4
  4. shepherd_core/data_models/base/shepherd.py +2 -0
  5. shepherd_core/data_models/content/energy_environment.py +1 -1
  6. shepherd_core/data_models/content/virtual_harvester.py +1 -1
  7. shepherd_core/data_models/content/virtual_source.py +18 -13
  8. shepherd_core/data_models/experiment/experiment.py +10 -10
  9. shepherd_core/data_models/experiment/observer_features.py +5 -6
  10. shepherd_core/data_models/task/observer_tasks.py +1 -1
  11. shepherd_core/data_models/task/testbed_tasks.py +7 -3
  12. shepherd_core/data_models/testbed/cape.py +1 -1
  13. shepherd_core/data_models/testbed/gpio.py +1 -1
  14. shepherd_core/data_models/testbed/mcu.py +1 -1
  15. shepherd_core/data_models/testbed/observer.py +1 -1
  16. shepherd_core/data_models/testbed/target.py +1 -1
  17. shepherd_core/data_models/testbed/testbed.py +1 -1
  18. shepherd_core/decoder_waveform/uart.py +1 -0
  19. shepherd_core/fw_tools/validation.py +1 -2
  20. shepherd_core/inventory/__init__.py +51 -1
  21. shepherd_core/inventory/system.py +8 -0
  22. shepherd_core/reader.py +19 -16
  23. shepherd_core/testbed_client/cache_path.py +15 -0
  24. shepherd_core/testbed_client/client.py +2 -3
  25. shepherd_core/testbed_client/fixtures.py +4 -1
  26. shepherd_core/testbed_client/user_model.py +6 -4
  27. shepherd_core/vsource/virtual_converter_model.py +1 -1
  28. shepherd_core/vsource/virtual_harvester_model.py +1 -0
  29. shepherd_core/vsource/virtual_source_model.py +1 -0
  30. shepherd_core/writer.py +5 -2
  31. {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.1.dist-info}/METADATA +49 -34
  32. shepherd_core-2024.4.1.dist-info/RECORD +64 -0
  33. {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.1.dist-info}/WHEEL +1 -1
  34. {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.1.dist-info}/top_level.txt +0 -1
  35. shepherd_core/data_models/content/_external_fixtures.yaml +0 -394
  36. shepherd_core/data_models/content/energy_environment_fixture.yaml +0 -50
  37. shepherd_core/data_models/content/virtual_harvester_fixture.yaml +0 -159
  38. shepherd_core/data_models/content/virtual_source_fixture.yaml +0 -229
  39. shepherd_core/data_models/testbed/cape_fixture.yaml +0 -94
  40. shepherd_core/data_models/testbed/gpio_fixture.yaml +0 -166
  41. shepherd_core/data_models/testbed/mcu_fixture.yaml +0 -19
  42. shepherd_core/data_models/testbed/observer_fixture.yaml +0 -220
  43. shepherd_core/data_models/testbed/target_fixture.yaml +0 -137
  44. shepherd_core/data_models/testbed/testbed_fixture.yaml +0 -25
  45. shepherd_core-2023.12.1.dist-info/RECORD +0 -117
  46. tests/__init__.py +0 -0
  47. tests/conftest.py +0 -64
  48. tests/data_models/__init__.py +0 -0
  49. tests/data_models/conftest.py +0 -14
  50. tests/data_models/example_cal_data.yaml +0 -31
  51. tests/data_models/example_cal_data_faulty.yaml +0 -29
  52. tests/data_models/example_cal_meas.yaml +0 -178
  53. tests/data_models/example_cal_meas_faulty1.yaml +0 -142
  54. tests/data_models/example_cal_meas_faulty2.yaml +0 -136
  55. tests/data_models/example_config_emulator.yaml +0 -41
  56. tests/data_models/example_config_experiment.yaml +0 -16
  57. tests/data_models/example_config_experiment_alternative.yaml +0 -14
  58. tests/data_models/example_config_harvester.yaml +0 -15
  59. tests/data_models/example_config_testbed.yaml +0 -26
  60. tests/data_models/example_config_virtsource.yaml +0 -78
  61. tests/data_models/test_base_models.py +0 -205
  62. tests/data_models/test_content_fixtures.py +0 -41
  63. tests/data_models/test_content_models.py +0 -282
  64. tests/data_models/test_examples.py +0 -48
  65. tests/data_models/test_experiment_models.py +0 -277
  66. tests/data_models/test_task_generation.py +0 -52
  67. tests/data_models/test_task_models.py +0 -131
  68. tests/data_models/test_testbed_fixtures.py +0 -47
  69. tests/data_models/test_testbed_models.py +0 -187
  70. tests/decoder_waveform/__init__.py +0 -0
  71. tests/decoder_waveform/test_decoder.py +0 -34
  72. tests/fw_tools/__init__.py +0 -0
  73. tests/fw_tools/conftest.py +0 -5
  74. tests/fw_tools/test_converter.py +0 -76
  75. tests/fw_tools/test_patcher.py +0 -66
  76. tests/fw_tools/test_validation.py +0 -56
  77. tests/inventory/__init__.py +0 -0
  78. tests/inventory/test_inventory.py +0 -20
  79. tests/test_cal_hw.py +0 -34
  80. tests/test_examples.py +0 -40
  81. tests/test_logger.py +0 -15
  82. tests/test_reader.py +0 -283
  83. tests/test_writer.py +0 -169
  84. tests/testbed_client/__init__.py +0 -0
  85. tests/vsource/__init__.py +0 -0
  86. tests/vsource/conftest.py +0 -49
  87. tests/vsource/test_converter.py +0 -161
  88. tests/vsource/test_harvester.py +0 -73
  89. tests/vsource/test_z.py +0 -5
  90. {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.1.dist-info}/zip-safe +0 -0
@@ -1,205 +0,0 @@
1
- import os
2
- from pathlib import Path
3
-
4
- import numpy as np
5
- import pytest
6
- from pydantic import ValidationError
7
-
8
- from shepherd_core.data_models.base.cal_measurement import CalMeasurementCape
9
- from shepherd_core.data_models.base.calibration import CalibrationCape
10
- from shepherd_core.data_models.base.calibration import CalibrationEmulator
11
- from shepherd_core.data_models.base.calibration import CalibrationHarvester
12
- from shepherd_core.data_models.base.calibration import CalibrationPair
13
- from shepherd_core.data_models.base.calibration import CalibrationSeries
14
- from shepherd_core.data_models.base.calibration import CapeData
15
- from shepherd_core.data_models.base.content import ContentModel
16
-
17
-
18
- def test_base_model_cape_data() -> None:
19
- CapeData(serial_number="xyz1")
20
-
21
-
22
- def test_base_model_cape_data_fail() -> None:
23
- with pytest.raises(ValueError):
24
- CapeData()
25
-
26
-
27
- def test_base_model_cal_pair_conv() -> None:
28
- cal = CalibrationPair(gain=4.9)
29
- val_raw = 500
30
- val_si = cal.raw_to_si(val_raw)
31
- val_rbw = cal.si_to_raw(val_si)
32
- assert val_raw == val_rbw
33
-
34
-
35
- def test_base_model_cal_pair_conv2() -> None:
36
- cal = CalibrationPair(gain=44)
37
- rng = np.random.default_rng()
38
- val_raw = rng.integers(low=0, high=2000, size=20)
39
- val_si = cal.raw_to_si(val_raw)
40
- val_rbw = cal.si_to_raw(val_si)
41
- assert val_raw.size == val_rbw.size
42
-
43
-
44
- def test_base_model_cal_series_min() -> None:
45
- CalibrationSeries()
46
-
47
-
48
- def test_base_model_cal_series_all() -> None:
49
- cal = CalibrationCape()
50
- _ = CalibrationSeries.from_cal(cal.harvester)
51
- _ = CalibrationSeries.from_cal(cal.emulator)
52
- _ = CalibrationSeries.from_cal(cal.emulator, emu_port_a=True)
53
- _ = CalibrationSeries.from_cal(cal.emulator, emu_port_a=False)
54
-
55
-
56
- def test_base_model_cal_hrv_min() -> None:
57
- cal = CalibrationHarvester()
58
- cs = cal.export_for_sysfs()
59
- assert len(cs) == 6
60
-
61
-
62
- def test_base_model_cal_emu_min() -> None:
63
- cal = CalibrationEmulator()
64
- cs = cal.export_for_sysfs()
65
- assert len(cs) == 6
66
-
67
-
68
- def test_base_model_cal_cape_bytestr() -> None:
69
- cal1 = CalibrationCape()
70
- cb = cal1.to_bytestr()
71
- cal2 = CalibrationCape.from_bytestr(cb)
72
- assert cal1.get_hash() == cal2.get_hash()
73
-
74
-
75
- def test_base_model_cal_cape_bytestr_with_cape_data() -> None:
76
- cal1 = CalibrationCape(cape=CapeData(serial_number="123"))
77
- cb = cal1.to_bytestr()
78
- cal2 = CalibrationCape.from_bytestr(cb, cal1.cape)
79
- assert cal1.get_hash() == cal2.get_hash()
80
-
81
-
82
- def test_base_model_cal_cape_example(tmp_path: Path) -> None:
83
- cal0 = CalMeasurementCape()
84
- path1 = Path(__file__).resolve().with_name("example_cal_data.yaml")
85
- cal1 = CalibrationCape.from_file(path1)
86
- path2 = tmp_path / "cal_data_new.yaml"
87
- cal1.to_file(path2)
88
- cal2 = CalibrationCape.from_file(path2)
89
- assert cal0.get_hash() != cal1.get_hash()
90
- assert cal1.get_hash() == cal2.get_hash()
91
-
92
-
93
- def test_base_model_cal_hrv_fault() -> None:
94
- path = Path(__file__).resolve().with_name("example_cal_data_faulty.yaml")
95
- cal = CalibrationCape.from_file(path)
96
- with pytest.raises(ValueError):
97
- _ = cal.harvester.export_for_sysfs()
98
-
99
-
100
- def test_base_model_cal_emu_fault() -> None:
101
- path = Path(__file__).resolve().with_name("example_cal_data_faulty.yaml")
102
- cal = CalibrationCape.from_file(path)
103
- with pytest.raises(ValueError):
104
- _ = cal.emulator.export_for_sysfs()
105
-
106
-
107
- def test_base_model_cal_meas_min() -> None:
108
- cm1 = CalMeasurementCape()
109
- cal1 = cm1.to_cal()
110
- cal2 = CalibrationCape()
111
- assert cal1.get_hash() == cal2.get_hash()
112
-
113
-
114
- def test_base_model_cal_meas_example() -> None:
115
- path1 = Path(__file__).resolve().with_name("example_cal_meas.yaml")
116
- cm1 = CalMeasurementCape.from_file(path1)
117
- cal1 = cm1.to_cal()
118
- cal2 = CalibrationCape()
119
- assert cal1.get_hash() != cal2.get_hash()
120
-
121
-
122
- def test_base_model_cal_meas_fault_correlation() -> None:
123
- path = Path(__file__).resolve().with_name("example_cal_meas_faulty1.yaml")
124
- with pytest.raises(ValueError):
125
- _ = CalMeasurementCape.from_file(path)
126
-
127
-
128
- def test_base_model_cal_meas_fault_no_pairs() -> None:
129
- path = Path(__file__).resolve().with_name("example_cal_meas_faulty2.yaml")
130
- with pytest.raises(ValidationError):
131
- _ = CalMeasurementCape.from_file(path)
132
-
133
-
134
- def test_base_model_content_str_repr() -> None:
135
- content = ContentModel(name="tricky", owner="peter", group="work")
136
- print(content)
137
- assert str(content) == "tricky"
138
-
139
-
140
- def test_base_model_content_public_group() -> None:
141
- _ = ContentModel(
142
- name="tricky",
143
- description="fake",
144
- owner="peter",
145
- group="work",
146
- visible2group=True,
147
- )
148
- with pytest.raises(ValueError):
149
- _ = ContentModel(name="tricky", owner="peter", group="work", visible2group=True)
150
-
151
-
152
- def test_base_model_content_public_all() -> None:
153
- _ = ContentModel(
154
- name="tricky", description="fake", owner="peter", group="work", visible2all=True
155
- )
156
- with pytest.raises(ValueError):
157
- _ = ContentModel(name="tricky", owner="peter", group="work", visible2all=True)
158
-
159
-
160
- # ContentModel below is used as inheritor of ShpModel
161
-
162
-
163
- def test_base_model_shepherd_scheme(tmp_path: Path) -> None:
164
- os.chdir(tmp_path)
165
- ContentModel.schema_to_file(tmp_path / "schema.yaml")
166
-
167
-
168
- def test_base_model_shepherd_min(tmp_path: Path) -> None:
169
- content = ContentModel(name="tricky", owner="peter", group="work")
170
- content.to_file(tmp_path / "content1.yaml", minimal=True)
171
- content.to_file(tmp_path / "content2.yaml", minimal=False)
172
- # minimal should produce min-set (input dict), but does not work currently
173
-
174
-
175
- def test_base_model_shepherd_fault_load_other(tmp_path: Path) -> None:
176
- path = tmp_path / "content.yaml"
177
- content = ContentModel(name="tricky", owner="peter", group="work")
178
- content.to_file(path)
179
- with pytest.raises(ValueError):
180
- CalibrationCape.from_file(path)
181
-
182
-
183
- def test_base_model_shepherd_fault_mutation() -> None:
184
- content = ContentModel(name="tricky", owner="peter", group="work")
185
- with pytest.raises(ValidationError):
186
- content.name = "whatever"
187
-
188
-
189
- def test_base_model_shepherd_fault_short_str() -> None:
190
- with pytest.raises(ValidationError):
191
- _ = ContentModel(name="", owner="peter", group="work")
192
-
193
-
194
- def test_base_model_shepherd_fault_long_str() -> None:
195
- with pytest.raises(ValidationError):
196
- _ = ContentModel(
197
- name="very_long_123456789_123456789_1234567890", owner="peter", group="work"
198
- )
199
-
200
-
201
- def test_base_model_shepherd_fault_unsafe_str() -> None:
202
- with pytest.raises(ValidationError):
203
- _ = ContentModel(name="fs_trouble<>", owner="peter", group="work")
204
- with pytest.raises(ValidationError):
205
- _ = ContentModel(name="unicode", owner="peter", group="work", description="🐍")
@@ -1,41 +0,0 @@
1
- from shepherd_core.data_models.content.energy_environment import EnergyEnvironment
2
- from shepherd_core.data_models.content.firmware import Firmware
3
- from shepherd_core.data_models.content.virtual_harvester import HarvesterPRUConfig
4
- from shepherd_core.data_models.content.virtual_harvester import VirtualHarvesterConfig
5
- from shepherd_core.data_models.content.virtual_source import ConverterPRUConfig
6
- from shepherd_core.data_models.content.virtual_source import VirtualSourceConfig
7
- from shepherd_core.testbed_client.fixtures import Fixtures
8
-
9
-
10
- def test_testbed_fixture_energy_environment() -> None:
11
- for fix in Fixtures()["EnergyEnvironment"]:
12
- EnergyEnvironment(name=fix["name"])
13
- EnergyEnvironment(id=fix["id"])
14
-
15
-
16
- def test_testbed_fixture_firmware() -> None:
17
- for fix in Fixtures()["Firmware"]:
18
- _id = fix["id"]
19
- if _id in {1001, 1002}:
20
- continue
21
- Firmware(name=fix["name"])
22
- Firmware(id=fix["id"])
23
-
24
-
25
- def test_experiment_fixture_vsrc() -> None:
26
- for fix in Fixtures()["VirtualSourceConfig"]:
27
- vsrc = VirtualSourceConfig(name=fix["name"])
28
- VirtualSourceConfig(id=fix["id"])
29
- ConverterPRUConfig.from_vsrc(vsrc, log_intermediate_node=False)
30
- ConverterPRUConfig.from_vsrc(vsrc, log_intermediate_node=True)
31
-
32
-
33
- def test_experiment_fixture_vhrv() -> None:
34
- for fix in Fixtures()["VirtualHarvesterConfig"]:
35
- if fix["name"] == "neutral":
36
- continue
37
- vhrv = VirtualHarvesterConfig(name=fix["name"])
38
- VirtualHarvesterConfig(id=fix["id"])
39
- HarvesterPRUConfig.from_vhrv(vhrv, for_emu=False)
40
- if int(fix["id"]) >= 1030:
41
- HarvesterPRUConfig.from_vhrv(vhrv, for_emu=True)
@@ -1,282 +0,0 @@
1
- from pathlib import Path
2
-
3
- import pytest
4
- from pydantic import ValidationError
5
-
6
- from shepherd_core import fw_tools
7
- from shepherd_core.data_models.content import EnergyDType
8
- from shepherd_core.data_models.content import EnergyEnvironment
9
- from shepherd_core.data_models.content import Firmware
10
- from shepherd_core.data_models.content import FirmwareDType
11
- from shepherd_core.data_models.content import VirtualHarvesterConfig
12
- from shepherd_core.data_models.content import VirtualSourceConfig
13
- from shepherd_core.data_models.content.virtual_source import ConverterPRUConfig
14
- from shepherd_core.data_models.testbed import MCU
15
-
16
- from .conftest import files_elf
17
-
18
-
19
- def test_content_model_ee_min1() -> None:
20
- EnergyEnvironment(
21
- id=9999,
22
- name="some",
23
- data_path="./file",
24
- data_type="isc_voc",
25
- duration=1,
26
- energy_Ws=0.1,
27
- owner="jane",
28
- group="wayne",
29
- )
30
-
31
-
32
- def test_content_model_ee_min2() -> None:
33
- EnergyEnvironment(
34
- id="98765",
35
- name="some",
36
- data_path="./file",
37
- data_type=EnergyDType.ivcurve,
38
- duration=999,
39
- energy_Ws=3.1,
40
- owner="jane",
41
- group="wayne",
42
- )
43
-
44
-
45
- def test_content_model_fw_faulty() -> None:
46
- with pytest.raises(ValueError):
47
- Firmware(
48
- id=9999,
49
- name="dome",
50
- mcu=MCU(name="nRF52"),
51
- data="xyz",
52
- data_type=FirmwareDType.base64_hex,
53
- owner="Obelix",
54
- group="Gaul",
55
- )
56
-
57
-
58
- @pytest.mark.elf
59
- @pytest.mark.converter
60
- @pytest.mark.parametrize("path_elf", files_elf)
61
- def test_content_model_fw_min(path_elf: Path, tmp_path: Path) -> None:
62
- path_hex = (tmp_path / (path_elf.stem + ".hex")).resolve()
63
- path_hex = fw_tools.elf_to_hex(path_elf, path_hex)
64
- Firmware(
65
- id=9999,
66
- name="dome",
67
- mcu=MCU(name="nRF52"),
68
- data=fw_tools.file_to_base64(path_hex),
69
- data_type=FirmwareDType.base64_hex,
70
- owner="Obelix",
71
- group="Gaul",
72
- )
73
-
74
-
75
- @pytest.mark.elf
76
- @pytest.mark.converter
77
- @pytest.mark.parametrize("path_elf", files_elf)
78
- def test_content_model_fw_from_elf(path_elf: Path) -> None:
79
- Firmware.from_firmware(
80
- file=path_elf,
81
- name="dome",
82
- owner="Obelix",
83
- group="Gaul",
84
- )
85
-
86
-
87
- @pytest.mark.elf
88
- @pytest.mark.converter
89
- @pytest.mark.parametrize("path_elf", files_elf)
90
- def test_content_model_fw_from_hex(path_elf: Path, tmp_path: Path) -> None:
91
- path_hex = (tmp_path / (path_elf.stem + ".hex")).resolve()
92
- path_hex = fw_tools.elf_to_hex(path_elf, path_hex)
93
- Firmware.from_firmware(
94
- file=path_hex,
95
- name="dome",
96
- owner="Obelix",
97
- group="Gaul",
98
- )
99
-
100
-
101
- def test_content_model_fw_from_hex_failing(tmp_path: Path) -> None:
102
- path_hex = tmp_path / "some.hex"
103
- with path_hex.open("w") as fd:
104
- fd.write("something")
105
- with pytest.raises(ValueError):
106
- Firmware.from_firmware(
107
- file=path_hex,
108
- name="dome",
109
- owner="Obelix",
110
- group="Gaul",
111
- )
112
-
113
-
114
- @pytest.mark.elf
115
- @pytest.mark.converter
116
- @pytest.mark.parametrize("path_elf", files_elf)
117
- def test_content_model_fw_extract_elf_to_dir(path_elf: Path, tmp_path: Path) -> None:
118
- fw = Firmware.from_firmware(
119
- file=path_elf,
120
- name="dome",
121
- owner="Obelix",
122
- group="Gaul",
123
- )
124
- file = fw.extract_firmware(tmp_path)
125
- assert file.exists()
126
- assert file.is_file()
127
-
128
-
129
- @pytest.mark.elf
130
- @pytest.mark.converter
131
- @pytest.mark.parametrize("path_elf", files_elf)
132
- def test_content_model_fw_extract_hex_to_dir(path_elf: Path, tmp_path: Path) -> None:
133
- path_hex = (tmp_path / (path_elf.stem + ".hex")).resolve()
134
- path_hex = fw_tools.elf_to_hex(path_elf, path_hex)
135
- fw = Firmware.from_firmware(
136
- file=path_hex,
137
- name="dome",
138
- owner="Obelix",
139
- group="Gaul",
140
- )
141
- file = fw.extract_firmware(tmp_path)
142
- assert file.exists()
143
- assert file.is_file()
144
-
145
-
146
- @pytest.mark.parametrize("path_elf", files_elf)
147
- def test_content_model_fw_extract_path_elf_to_dir(path_elf: Path, tmp_path: Path) -> None:
148
- assert path_elf.exists()
149
- fw = Firmware(
150
- data=path_elf,
151
- data_type=FirmwareDType.path_elf,
152
- mcu={"name": "MSP430FR"},
153
- name="dome",
154
- owner="Obelix",
155
- group="Gaul",
156
- )
157
- file = fw.extract_firmware(tmp_path)
158
- assert file.exists()
159
- assert file.is_file()
160
-
161
-
162
- @pytest.mark.elf
163
- @pytest.mark.converter
164
- @pytest.mark.parametrize("path_elf", files_elf)
165
- def test_content_model_fw_extract_path_hex_to_dir(path_elf: Path, tmp_path: Path) -> None:
166
- path_hex = (tmp_path / (path_elf.stem + ".hex")).resolve()
167
- path_hex = fw_tools.elf_to_hex(path_elf, path_hex)
168
- assert path_hex.exists()
169
- fw = Firmware(
170
- data=path_hex,
171
- data_type=FirmwareDType.path_hex,
172
- mcu={"name": "MSP430FR"},
173
- name="dome",
174
- owner="Obelix",
175
- group="Gaul",
176
- )
177
- file = fw.extract_firmware(tmp_path)
178
- assert file.exists()
179
- assert file.is_file()
180
-
181
-
182
- def test_content_model_hrv_min() -> None:
183
- hrv = VirtualHarvesterConfig(
184
- id=9999,
185
- name="whatever",
186
- owner="jane",
187
- group="wayne",
188
- algorithm="mppt_opt",
189
- )
190
- assert hrv.get_datatype() == "ivsample"
191
-
192
-
193
- def test_content_model_hrv_neutral() -> None:
194
- with pytest.raises(ValueError):
195
- _ = VirtualHarvesterConfig(name="neutral")
196
-
197
-
198
- @pytest.mark.parametrize("name", ["iv110", "cv24", "mppt_voc", "mppt_po"])
199
- def test_content_model_hrv_by_name(name: str) -> None:
200
- _ = VirtualHarvesterConfig(name=name)
201
-
202
-
203
- @pytest.mark.parametrize("uid", [1013, 1020, 1032, 1044, 1045, 1046])
204
- def test_content_model_hrv_by_id(uid: int) -> None:
205
- _ = VirtualHarvesterConfig(id=uid)
206
-
207
-
208
- def test_content_model_hrv_steps() -> None:
209
- hrv = VirtualHarvesterConfig(
210
- name="ivcurves", voltage_min_mV=1000, voltage_max_mV=4000, samples_n=11
211
- )
212
- assert hrv.voltage_step_mV == 300
213
-
214
-
215
- def test_content_model_hrv_faulty_voltage0() -> None:
216
- with pytest.raises(ValidationError):
217
- _ = VirtualHarvesterConfig(name="iv110", voltage_max_mV=5001)
218
- with pytest.raises(ValidationError):
219
- _ = VirtualHarvesterConfig(name="iv110", voltage_min_mV=-1)
220
-
221
-
222
- def test_content_model_hrv_faulty_voltage1() -> None:
223
- with pytest.raises(ValueError):
224
- _ = VirtualHarvesterConfig(name="iv110", voltage_min_mV=4001, voltage_max_mV=4000)
225
-
226
-
227
- def test_content_model_hrv_faulty_voltage2() -> None:
228
- with pytest.raises(ValueError):
229
- _ = VirtualHarvesterConfig(name="iv110", voltage_mV=4001, voltage_max_mV=4000)
230
-
231
-
232
- def test_content_model_hrv_faulty_voltage3() -> None:
233
- with pytest.raises(ValueError):
234
- _ = VirtualHarvesterConfig(name="iv110", voltage_mV=4000, voltage_min_mV=4001)
235
-
236
-
237
- @pytest.mark.parametrize("name", ["ivcurves", "iv1000", "isc_voc"])
238
- def test_content_model_hrv_faulty_emu(name: str) -> None:
239
- hrv = VirtualHarvesterConfig(name=name)
240
- with pytest.raises(ValueError):
241
- _ = VirtualSourceConfig(name="dio_cap", harvester=hrv)
242
-
243
-
244
- def test_content_model_src_min() -> None:
245
- VirtualSourceConfig(
246
- id=9999,
247
- name="new_src",
248
- owner="jane",
249
- group="wayne",
250
- )
251
-
252
-
253
- def test_content_model_src_force_warning() -> None:
254
- src = VirtualSourceConfig(
255
- name="BQ25570",
256
- C_output_uF=200,
257
- C_intermediate_uF=100,
258
- )
259
- ConverterPRUConfig.from_vsrc(src)
260
- # -> triggers warning currently
261
-
262
-
263
- def test_content_model_src_force_other_hysteresis1() -> None:
264
- src = VirtualSourceConfig(
265
- name="BQ25570",
266
- V_intermediate_enable_threshold_mV=4000,
267
- V_intermediate_disable_threshold_mV=3999,
268
- V_output_mV=2000,
269
- V_buck_drop_mV=100,
270
- )
271
- ConverterPRUConfig.from_vsrc(src)
272
-
273
-
274
- def test_content_model_src_force_other_hysteresis2() -> None:
275
- src = VirtualSourceConfig(
276
- name="BQ25570",
277
- V_intermediate_enable_threshold_mV=1000,
278
- V_intermediate_disable_threshold_mV=999,
279
- V_output_mV=2000,
280
- V_buck_drop_mV=100,
281
- )
282
- ConverterPRUConfig.from_vsrc(src)
@@ -1,48 +0,0 @@
1
- from pathlib import Path
2
-
3
- from shepherd_core.data_models.content import VirtualSourceConfig
4
- from shepherd_core.data_models.experiment import Experiment
5
- from shepherd_core.data_models.task import EmulationTask
6
- from shepherd_core.data_models.task import HarvestTask
7
- from shepherd_core.data_models.testbed.testbed import Testbed as TasteBad
8
-
9
- from .conftest import load_yaml
10
-
11
- # ⤷ TasteBad avoids pytest-warning
12
-
13
-
14
- def test_example_emu() -> None:
15
- data_dict = load_yaml("example_config_emulator.yaml")
16
- assert data_dict["mode"] == "emulator"
17
- emu = EmulationTask(**data_dict["parameters"])
18
- print(emu)
19
-
20
-
21
- def test_example_hrv() -> None:
22
- data_dict = load_yaml("example_config_harvester.yaml")
23
- assert data_dict["mode"] == "harvester"
24
- emu = HarvestTask(**data_dict["parameters"])
25
- print(emu)
26
-
27
-
28
- def test_example_exp_recommended() -> None:
29
- # new way
30
- path = Path(__file__).with_name("example_config_experiment.yaml")
31
- Experiment.from_file(path)
32
-
33
-
34
- def test_example_exp() -> None:
35
- # non-optimal / old way
36
- data_dict = load_yaml("example_config_experiment_alternative.yaml")
37
- Experiment(**data_dict)
38
-
39
-
40
- def test_example_tb() -> None:
41
- data_dict = load_yaml("example_config_testbed.yaml")
42
- print(data_dict)
43
- TasteBad(**data_dict)
44
-
45
-
46
- def test_example_vsrc() -> None:
47
- data_dict = load_yaml("example_config_virtsource.yaml")
48
- VirtualSourceConfig(**data_dict["VirtualSource"])