Skip to content

Commit f38d322

Browse files
committed
MCU8MASS-2405 Adapt tests for NB-IoT
1 parent ef590ac commit f38d322

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

test/test_examples.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ def example_test_data():
102102
"expectation": "\\[INFO\\] Command written successfully, the response was:"
103103
},
104104
{
105-
"expectation": "\\+CEREG: 5,5,\"[a-zA-Z0-9]{1,}\",\"[a-zA-Z0-9]{1,}\",\\d{1,}"
105+
"expectation": "\\+CEREG: 5,[1|5],\"[a-zA-Z0-9]{1,}\",\"[a-zA-Z0-9]{1,}\",\\d{1,}"
106106
},
107107
{
108108
"expectation": ""
109109
},
110110
{
111-
"expectation": "The value was: 5"
111+
"expectation": "The value was: [1|5]"
112112
},
113113
],
114114
"debug_modem": [
@@ -211,7 +211,8 @@ def example_test_data():
211211
"expectation": "\\[INFO\\] Connecting to operator.{0,}OK!"
212212
},
213213
{
214-
"expectation": "\\[INFO\\] Connected to operator: (.*)"
214+
"expectation": "\\[INFO\\] Connected to operator: (.*)",
215+
"timeout": 60
215216
},
216217
{
217218
"expectation": "\\[INFO\\] ---- Testing HTTP ----"
@@ -695,13 +696,15 @@ def program(request, backend):
695696

696697
hex_file = build_directory / f"{os.path.basename(sketch_path)}.hex"
697698

698-
memory_segments = read_memories_from_hex(hex_file, backend.device_memory_info)
699+
memory_segments = read_memories_from_hex(
700+
hex_file, backend.device_memory_info)
699701
backend.erase(MemoryNameAliases.ALL, address=None)
700702

701703
for segment in memory_segments:
702704
memory_name = segment.memory_info[DeviceMemoryInfoKeys.NAME]
703705
backend.write_memory(segment.data, memory_name, segment.offset)
704-
verify_ok = backend.verify_memory(segment.data, memory_name, segment.offset)
706+
verify_ok = backend.verify_memory(
707+
segment.data, memory_name, segment.offset)
705708

706709
assert verify_ok, "Verification of program memory failed"
707710

@@ -750,12 +753,15 @@ def run_example(request, backend, example_test_data):
750753
try:
751754
response = re.search(expectation, output)
752755
except Exception as exception:
753-
pytest.fail(f"\tRegex error for string \"{expectation}\". The error was: {str(exception)}")
756+
pytest.fail(
757+
f"\tRegex error for string \"{expectation}\". The error was: {str(exception)}")
754758

755-
formatted_output = output.replace("\r", "\\r").replace("\n", "\\n")
759+
formatted_output = output.replace(
760+
"\r", "\\r").replace("\n", "\\n")
756761
assert response != None, f"\tDid not get the expected response \"{expectation}\" within the timeout of {timeout}, got: \"{formatted_output}\""
757762

758-
formatted_response = response.group(0).replace("\r", "\\r").replace("\n", "\\n")
763+
formatted_response = response.group(0).replace(
764+
"\r", "\\r").replace("\n", "\\n")
759765

760766
print(f"\tGot valid response: {formatted_response}")
761767

0 commit comments

Comments
 (0)