@@ -121,3 +121,242 @@ tests:
121121 prompt : " Ces valeurs sont-elles cohérentes (pression ~1013 hPa, température ambiante) ?"
122122 expect_true : true
123123 mode : [hardware]
124+
125+ # ---------------------------------------------------------------------------
126+ # Init / identification
127+ # ---------------------------------------------------------------------------
128+
129+ - name : " Device absent raises exception"
130+ action : script
131+ script : |
132+ from wsen_pads import WSEN_PADS
133+ from wsen_pads.exceptions import WSENPADSDeviceNotFound
134+
135+ try:
136+ i2c.scan = lambda: []
137+ WSEN_PADS(i2c, address=0x5D)
138+ result = False
139+ except WSENPADSDeviceNotFound:
140+ result = True
141+ except Exception:
142+ result = False
143+ expect_true : true
144+ mode : [mock]
145+
146+ - name : " Invalid DEVICE_ID raises exception"
147+ action : script
148+ script : |
149+ from wsen_pads import WSEN_PADS
150+ from wsen_pads.exceptions import WSENPADSInvalidDevice
151+
152+ original = i2c._registers[0x0F]
153+ i2c._registers[0x0F] = bytes([0x00])
154+
155+ try:
156+ WSEN_PADS(i2c, address=0x5D)
157+ result = False
158+ except WSENPADSInvalidDevice:
159+ result = True
160+ except Exception:
161+ result = False
162+
163+ i2c._registers[0x0F] = original
164+ expect_true : true
165+ mode : [mock]
166+
167+ - name : " Boot timeout raises exception at init"
168+ action : script
169+ script : |
170+ from wsen_pads import WSEN_PADS
171+ from wsen_pads.exceptions import WSENPADSTimeout
172+
173+ original = i2c._registers[0x24]
174+ i2c._registers[0x24] = bytes([0x80]) # INT_SOURCE_BOOT_ON
175+
176+ try:
177+ WSEN_PADS(i2c, address=0x5D)
178+ result = False
179+ except WSENPADSTimeout:
180+ result = True
181+ except Exception:
182+ result = False
183+
184+ i2c._registers[0x24] = original
185+ expect_true : true
186+ mode : [mock]
187+
188+ # ---------------------------------------------------------------------------
189+ # Continuous mode validation
190+ # ---------------------------------------------------------------------------
191+
192+ - name : " set_continuous rejects invalid ODR"
193+ action : script
194+ script : |
195+ try:
196+ dev.set_continuous(odr=99)
197+ result = False
198+ except ValueError:
199+ result = True
200+ except Exception:
201+ result = False
202+ expect_true : true
203+ mode : [mock]
204+
205+ - name : " set_continuous rejects low-noise at 100 Hz"
206+ action : script
207+ script : |
208+ try:
209+ dev.set_continuous(odr=0x06, low_noise=True)
210+ result = False
211+ except ValueError:
212+ result = True
213+ except Exception:
214+ result = False
215+ expect_true : true
216+ mode : [mock]
217+
218+ - name : " set_continuous rejects low-noise at 200 Hz"
219+ action : script
220+ script : |
221+ try:
222+ dev.set_continuous(odr=0x07, low_noise=True)
223+ result = False
224+ except ValueError:
225+ result = True
226+ except Exception:
227+ result = False
228+ expect_true : true
229+ mode : [mock]
230+
231+ # ---------------------------------------------------------------------------
232+ # Status helpers
233+ # ---------------------------------------------------------------------------
234+
235+ - name : " pressure_ready false when status empty"
236+ action : script
237+ script : |
238+ i2c._registers[0x27] = bytes([0x00])
239+ result = dev.pressure_ready()
240+ i2c._registers[0x27] = bytes([0x03])
241+ expect_false : true
242+ mode : [mock]
243+
244+ - name : " temperature_ready false when status empty"
245+ action : script
246+ script : |
247+ i2c._registers[0x27] = bytes([0x00])
248+ result = dev.temperature_ready()
249+ i2c._registers[0x27] = bytes([0x03])
250+ expect_false : true
251+ mode : [mock]
252+
253+ - name : " data_ready false when status empty"
254+ action : script
255+ script : |
256+ i2c._registers[0x27] = bytes([0x00])
257+ result = dev.data_ready()
258+ i2c._registers[0x27] = bytes([0x03])
259+ expect_false : true
260+ mode : [mock]
261+
262+ - name : " pressure_ready true when only pressure available"
263+ action : script
264+ script : |
265+ i2c._registers[0x27] = bytes([0x01]) # STATUS_P_DA
266+ result = dev.pressure_ready()
267+ i2c._registers[0x27] = bytes([0x03])
268+ expect_true : true
269+ mode : [mock]
270+
271+ - name : " temperature_ready true when only temperature available"
272+ action : script
273+ script : |
274+ i2c._registers[0x27] = bytes([0x02]) # STATUS_T_DA
275+ result = dev.temperature_ready()
276+ i2c._registers[0x27] = bytes([0x03])
277+ expect_true : true
278+ mode : [mock]
279+
280+ - name : " data_ready false when only pressure available"
281+ action : script
282+ script : |
283+ i2c._registers[0x27] = bytes([0x01]) # STATUS_P_DA
284+ result = dev.data_ready()
285+ i2c._registers[0x27] = bytes([0x03])
286+ expect_false : true
287+ mode : [mock]
288+
289+ - name : " data_ready false when only temperature available"
290+ action : script
291+ script : |
292+ i2c._registers[0x27] = bytes([0x02]) # STATUS_T_DA
293+ result = dev.data_ready()
294+ i2c._registers[0x27] = bytes([0x03])
295+ expect_false : true
296+ mode : [mock]
297+
298+ - name : " data_ready true when pressure and temperature available"
299+ action : script
300+ script : |
301+ i2c._registers[0x27] = bytes([0x03]) # STATUS_P_DA | STATUS_T_DA
302+ result = dev.data_ready()
303+ expect_true : true
304+ mode : [mock]
305+
306+ # ---------------------------------------------------------------------------
307+ # Reset / reboot
308+ # ---------------------------------------------------------------------------
309+
310+ - name : " soft_reset reapplies default configuration"
311+ action : script
312+ script : |
313+ dev.set_continuous(odr=0x03, low_noise=True, low_pass=True, low_pass_strong=True)
314+ dev.soft_reset()
315+
316+ ctrl1 = i2c._registers[0x10][0]
317+ ctrl2 = i2c._registers[0x11][0]
318+
319+ bdu_ok = (ctrl1 & 0x02) == 0x02
320+ odr_power_down = (ctrl1 & 0x70) == 0x00
321+ auto_inc_ok = (ctrl2 & 0x10) == 0x10
322+ low_noise_off = (ctrl2 & 0x02) == 0x00
323+
324+ result = bdu_ok and odr_power_down and auto_inc_ok and low_noise_off
325+ expect_true : true
326+ mode : [mock]
327+
328+ - name : " reboot reapplies default configuration"
329+ action : script
330+ script : |
331+ dev.set_continuous(odr=0x03, low_noise=False, low_pass=True, low_pass_strong=True)
332+ i2c._registers[0x24] = bytes([0x00]) # boot already finished
333+ dev.reboot()
334+
335+ ctrl1 = i2c._registers[0x10][0]
336+ ctrl2 = i2c._registers[0x11][0]
337+
338+ bdu_ok = (ctrl1 & 0x02) == 0x02
339+ odr_power_down = (ctrl1 & 0x70) == 0x00
340+ auto_inc_ok = (ctrl2 & 0x10) == 0x10
341+ low_noise_off = (ctrl2 & 0x02) == 0x00
342+
343+ result = bdu_ok and odr_power_down and auto_inc_ok and low_noise_off
344+ expect_true : true
345+ mode : [mock]
346+
347+ # ---------------------------------------------------------------------------
348+ # Calibration
349+ # ---------------------------------------------------------------------------
350+
351+ - name : " Temperature calibration rejects identical measured points"
352+ action : script
353+ script : |
354+ try:
355+ dev.calibrate_temperature(20.0, 25.0, 30.0, 25.0)
356+ result = False
357+ except ValueError:
358+ result = True
359+ except Exception:
360+ result = False
361+ expect_true : true
362+ mode : [mock]
0 commit comments