mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-27 04:55:53 +00:00
test: format all test scripts
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import logging
|
||||
import os
|
||||
@@ -8,6 +8,7 @@ import random
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from pytest_embedded_idf.utils import idf_parametrize
|
||||
|
||||
try:
|
||||
from idf_http_server_test import adder as client
|
||||
@@ -23,19 +24,16 @@ from pytest_embedded import Dut
|
||||
# > make print_flash_cmd | tail -n 1 > build/download.config
|
||||
|
||||
|
||||
@pytest.mark.esp32
|
||||
@pytest.mark.esp32c3
|
||||
@pytest.mark.esp32s3
|
||||
@pytest.mark.wifi_router
|
||||
@idf_parametrize('target', ['esp32', 'esp32c3', 'esp32s3'], indirect=['target'])
|
||||
def test_examples_protocol_http_server_persistence(dut: Dut) -> None:
|
||||
|
||||
# Get binary file
|
||||
binary_file = os.path.join(dut.app.binary_path, 'persistent_sockets.bin')
|
||||
bin_size = os.path.getsize(binary_file)
|
||||
logging.info('http_server_bin_size : {}KB'.format(bin_size // 1024))
|
||||
|
||||
# Upload binary and start testing
|
||||
logging.info('Starting http_server persistance test app')
|
||||
logging.info('Starting http_server persistence test app')
|
||||
|
||||
# Parse IP address of STA
|
||||
logging.info('Waiting to connect with AP')
|
||||
@@ -70,7 +68,7 @@ def test_examples_protocol_http_server_persistence(dut: Dut) -> None:
|
||||
dut.expect('Logging out', timeout=30)
|
||||
|
||||
# Test PUT request and initialize session context
|
||||
num = random.randint(0,100)
|
||||
num = random.randint(0, 100)
|
||||
client.putreq(conn, '/adder', str(num))
|
||||
visitor += 1
|
||||
dut.expect('/adder visitor count = ' + str(visitor), timeout=30)
|
||||
@@ -78,7 +76,7 @@ def test_examples_protocol_http_server_persistence(dut: Dut) -> None:
|
||||
dut.expect('PUT allocating new session', timeout=30)
|
||||
|
||||
# Retest PUT request and change session context value
|
||||
num = random.randint(0,100)
|
||||
num = random.randint(0, 100)
|
||||
logging.info('Adding: {}'.format(num))
|
||||
client.putreq(conn, '/adder', str(num))
|
||||
visitor += 1
|
||||
@@ -95,7 +93,7 @@ def test_examples_protocol_http_server_persistence(dut: Dut) -> None:
|
||||
pass
|
||||
|
||||
# Test POST request and session persistence
|
||||
random_nums = [random.randint(0,100) for _ in range(100)]
|
||||
random_nums = [random.randint(0, 100) for _ in range(100)]
|
||||
for num in random_nums:
|
||||
logging.info('Adding: {}'.format(num))
|
||||
client.postreq(conn, '/adder', str(num))
|
||||
@@ -120,7 +118,7 @@ def test_examples_protocol_http_server_persistence(dut: Dut) -> None:
|
||||
logging.info('Validating user context data')
|
||||
# Start another session to check user context data
|
||||
client.start_session(got_ip, got_port)
|
||||
num = random.randint(0,100)
|
||||
num = random.randint(0, 100)
|
||||
client.putreq(conn, '/adder', str(num))
|
||||
visitor += 1
|
||||
dut.expect('/adder visitor count = ' + str(visitor), timeout=30)
|
||||
|
||||
Reference in New Issue
Block a user