11import os
22import sys
33import json
4+ import pytest
45import requests .exceptions # Used for handling HTTP errors from nRF Cloud API
56
67# Ensure the utils directory is in the Python path
@@ -97,7 +98,7 @@ def _claim_device_on_nrf_cloud(dut_cloud, attestation_token: str):
9798def _wait_for_provisioning_completion_and_cloud_connection (dut_cloud , timeout : int = 240 ):
9899 logger .info ("Waiting for provisioning to complete and device to connect to nRF Cloud..." )
99100
100- dut_cloud .uart .wait_for_str ("cloud: Provisioning finished" , timeout = timeout )
101+ dut_cloud .uart .wait_for_str ("cloud: nrf_provisioning_callback: Provisioning finished" , timeout = timeout )
101102 dut_cloud .uart .wait_for_str ("cloud: Connected to Cloud" , timeout = timeout )
102103
103104 logger .info ("Device provisioned and connected to nRF Cloud." )
@@ -220,8 +221,8 @@ def _run_reprovisioning_expecting_no_commands(dut_cloud):
220221 logger .info ("--- Phase 3: Reprovisioning Expecting No Commands Completed Successfully ---" )
221222
222223# --- Main Test ---
223-
224- def test_device_provisioning (dut_cloud , hex_file ):
224+ @ pytest . mark . parametrize ( "_" , range ( 1 , 10 ))
225+ def test_device_provisioning (_ , dut_cloud , hex_file ):
225226 """
226227 Tests the full device provisioning and reprovisioning lifecycle:
227228 1. Initial provisioning: Flashes, gets attestation token, claims on nRF Cloud, connects.
@@ -231,12 +232,7 @@ def test_device_provisioning(dut_cloud, hex_file):
231232 connects to nRF Cloud Provisioning Service, but finds no new commands to process and establishes
232233 a connection without reprovisioning.
233234 """
235+ _run_initial_provisioning (dut_cloud , hex_file )
236+ _run_reprovisioning (dut_cloud )
237+ _run_reprovisioning_expecting_no_commands (dut_cloud )
234238
235- for i in range (1 , 21 ):
236- logger .info (f"--- Starting Test Iteration: { i } /20 ---" )
237- _run_initial_provisioning (dut_cloud , hex_file )
238- _run_reprovisioning (dut_cloud )
239- _run_reprovisioning_expecting_no_commands (dut_cloud )
240- logger .info (f"--- Completed Test Iteration: { i } /20 ---" )
241-
242- logger .info ("Device provisioning and reprovisioning test completed successfully." )
0 commit comments