50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
import pytest
|
|
|
|
def test_pdp_context(bg95_mock):
|
|
"""Test PDP context configuration and activation."""
|
|
# Configure
|
|
assert bg95_mock.configure_pdp_context(1, "IP", "iot.apn") is True
|
|
|
|
# Activate
|
|
assert bg95_mock.activate_pdp_context(1) is True
|
|
|
|
# Check IP
|
|
ip = bg95_mock.get_ip_address(1)
|
|
assert ip == "10.0.0.5"
|
|
|
|
def test_socket_lifecycle(bg95_mock):
|
|
"""Test opening, sending, and closing a socket."""
|
|
# Open
|
|
# Note: open_socket returns -1 on failure, or 0/result on success/URC
|
|
# In our mock, it returns 0 via URC simulation.
|
|
# The synchronous open_socket method waits for it.
|
|
res = bg95_mock.open_socket(1, 0, "TCP", "8.8.8.8", 80)
|
|
assert res == 0
|
|
|
|
# Send
|
|
assert bg95_mock.send_data_hex(0, b"Hello") is True
|
|
|
|
# Receive
|
|
data = bg95_mock.receive_data(0, 100)
|
|
assert data == b"Hello from Mock!"
|
|
|
|
# Close
|
|
assert bg95_mock.close_socket(0) is True
|
|
|
|
def test_file_operations(bg95_mock):
|
|
"""Test file upload and delete."""
|
|
assert bg95_mock.upload_file("test.txt", b"content") is True
|
|
assert bg95_mock.delete_file("test.txt") is True
|
|
|
|
def test_engineering_info(bg95_mock):
|
|
"""Test retrieving serving cell info."""
|
|
info = bg95_mock.get_serving_cell_info()
|
|
assert info['tech'] == "LTE"
|
|
assert info['cellid'] == "1A2B3C"
|
|
assert info['rsrp'] == -105
|
|
|
|
def test_sim_diagnostics(bg95_mock):
|
|
"""Test reading forbidden PLMNs."""
|
|
fplmns = bg95_mock.read_forbidden_plmns()
|
|
# Mock returns "64F010..." -> 460-01
|
|
assert "460-01" in fplmns
|