From aa7cdbd36f823191aa21569d2eda9979bfca27d6 Mon Sep 17 00:00:00 2001 From: narawat Date: Fri, 6 Mar 2026 08:19:15 +0700 Subject: [PATCH] update --- README.md | 32 ++++++++--------- docs/architecture.md | 6 ++-- docs/implementation.md | 18 +++++----- examples/tutorial.md | 40 ++++++++++----------- examples/walkthrough.md | 22 ++++++------ src/{natbridge.js => natsbridge.js} | 0 src/{natbridge.py => natsbridge.py} | 2 +- src/{natbridge_mpy.py => natsbridge_mpy.py} | 0 test/test_js_binary_receiver.js | 2 +- test/test_js_binary_sender.js | 2 +- test/test_js_dictionary_receiver.js | 2 +- test/test_js_dictionary_sender.js | 2 +- test/test_js_mix_payloads_sender.js | 2 +- test/test_js_table_receiver.js | 2 +- test/test_js_table_sender.js | 2 +- test/test_js_text_receiver.js | 2 +- test/test_js_text_sender.js | 2 +- test/test_mpy_binary_receiver.py | 4 +-- test/test_mpy_binary_sender.py | 4 +-- test/test_mpy_dictionary_receiver.py | 4 +-- test/test_mpy_dictionary_sender.py | 4 +-- test/test_mpy_text_receiver.py | 4 +-- test/test_mpy_text_sender.py | 4 +-- test/test_py_binary_receiver.py | 2 +- test/test_py_binary_sender.py | 2 +- test/test_py_dictionary_receiver.py | 2 +- test/test_py_dictionary_sender.py | 2 +- test/test_py_mix_payloads_sender.py | 2 +- test/test_py_table_sender.py | 2 +- test/test_py_text_receiver.py | 2 +- test/test_py_text_sender.py | 2 +- 31 files changed, 89 insertions(+), 89 deletions(-) rename src/{natbridge.js => natsbridge.js} (100%) rename src/{natbridge.py => natsbridge.py} (99%) rename src/{natbridge_mpy.py => natsbridge_mpy.py} (100%) diff --git a/README.md b/README.md index be22435..bfa2bac 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,9 @@ NATSBridge enables seamless communication across multiple platforms through NATS | Platform | Implementation | Features | |----------|----------------|----------| | **Julia** | [`src/NATSBridge.jl`](src/NATSBridge.jl) | Full feature set, Arrow IPC, multiple dispatch | -| **JavaScript** | [`src/natbridge.js`](src/natbridge.js) | Node.js & browser, async/await | -| **Python** | [`src/natbridge.py`](src/natbridge.py) | Desktop Python, asyncio, type hints | -| **MicroPython** | [`src/natbridge_mpy.py`](src/natbridge_mpy.py) | Memory-constrained, synchronous API | +| **JavaScript** | [`src/natsbridge.js`](src/natsbridge.js) | Node.js & browser, async/await | +| **Python** | [`src/natsbridge.py`](src/natsbridge.py) | Desktop Python, asyncio, type hints | +| **MicroPython** | [`src/natsbridge_mpy.py`](src/natsbridge_mpy.py) | Memory-constrained, synchronous API | ### Platform Comparison @@ -332,7 +332,7 @@ env, env_json_str = NATSBridge.smartsend( #### JavaScript ```javascript -const NATSBridge = require('natbridge'); +const NATSBridge = require('natsbridge'); const [env, env_json_str] = await NATSBridge.smartsend( subject, @@ -361,7 +361,7 @@ const [env, env_json_str] = await NATSBridge.smartsend( #### Python ```python -from natbridge import NATSBridge +from natsbridge import NATSBridge env, env_json_str = await NATSBridge.smartsend( subject: str, @@ -388,7 +388,7 @@ env, env_json_str = await NATSBridge.smartsend( #### MicroPython ```python -from natbridge import NATSBridge +from natsbridge import NATSBridge # Limited to direct transport (< 100KB threshold) env, env_json_str = NATSBridge.smartsend( @@ -551,7 +551,7 @@ env, env_json_str = NATSBridge.smartsend("/chat/room1", data; fileserver_url="ht #### JavaScript ```javascript -const NATSBridge = require('natbridge'); +const NATSBridge = require('natsbridge'); const data = [ ["message_text", "Hello!", "text"], @@ -569,7 +569,7 @@ const [env, env_json_str] = await NATSBridge.smartsend( #### Python ```python -from natbridge import NATSBridge +from natsbridge import NATSBridge data = [ ("message_text", "Hello!", "text"), @@ -606,7 +606,7 @@ env, env_json_str = NATSBridge.smartsend("/device/config", data) #### JavaScript ```javascript -const NATSBridge = require('natbridge'); +const NATSBridge = require('natsbridge'); const config = { wifi_ssid: "MyNetwork", @@ -623,7 +623,7 @@ const [env, env_json_str] = await NATSBridge.smartsend( #### Python ```python -from natbridge import NATSBridge +from natsbridge import NATSBridge config = { "wifi_ssid": "MyNetwork", @@ -658,7 +658,7 @@ env, env_json_str = NATSBridge.smartsend("/data/analysis", data) #### JavaScript ```javascript -const NATSBridge = require('natbridge'); +const NATSBridge = require('natsbridge'); const df = [ { id: 1, name: "Alice", score: 95 }, @@ -675,7 +675,7 @@ const [env, env_json_str] = await NATSBridge.smartsend( #### Python ```python -from natbridge import NATSBridge +from natsbridge import NATSBridge import pandas as pd df = pd.DataFrame({ @@ -735,7 +735,7 @@ end #### JavaScript ```javascript -const NATSBridge = require('natbridge'); +const NATSBridge = require('natsbridge'); // Requester const [env, env_json_str] = await NATSBridge.smartsend( @@ -748,7 +748,7 @@ const [env, env_json_str] = await NATSBridge.smartsend( ```javascript // Responder const nats = require('nats'); -const NATSBridge = require('natbridge'); +const NATSBridge = require('natsbridge'); async function testResponder() { const conn = await nats.connect('nats://localhost:4222'); @@ -782,7 +782,7 @@ async function testResponder() { #### Python ```python -from natbridge import NATSBridge +from natsbridge import NATSBridge # Requester env, env_json_str = await NATSBridge.smartsend( @@ -795,7 +795,7 @@ env, env_json_str = await NATSBridge.smartsend( ```python # Responder -from natbridge import NATSBridge +from natsbridge import NATSBridge import asyncio import nats diff --git a/docs/architecture.md b/docs/architecture.md index b04a771..500f988 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -82,7 +82,7 @@ env = smartreceive(msg; fileserver_download_handler=_fetch_with_backoff) **JavaScript:** ```javascript -const NATSBridge = require('natbridge'); +const NATSBridge = require('natsbridge'); // Send const [env, env_json_str] = await NATSBridge.smartsend( @@ -104,7 +104,7 @@ const env = await NATSBridge.smartreceive(msg, { **Python:** ```python -from natbridge import NATSBridge +from natsbridge import NATSBridge # Send env, env_json_str = NATSBridge.smartsend( @@ -124,7 +124,7 @@ env = NATSBridge.smartreceive( **MicroPython:** ```python -from natbridge import NATSBridge +from natsbridge import NATSBridge # Send (limited to direct transport due to memory constraints) env, env_json_str = NATSBridge.smartsend( diff --git a/docs/implementation.md b/docs/implementation.md index 88d9af3..49b9c1f 100644 --- a/docs/implementation.md +++ b/docs/implementation.md @@ -16,9 +16,9 @@ This document describes the implementation of the high-performance, bi-direction | Language | Implementation File | Description | |----------|---------------------|-------------| | **Julia** | [`src/NATSBridge.jl`](../src/NATSBridge.jl) | Full Julia implementation with Arrow IPC support | -| **JavaScript** | `src/natbridge.js` | Node.js/browser implementation | -| **Python** | `src/natbridge.py` | Desktop Python implementation | -| **MicroPython** | `src/natbridge_mpy.py` | MicroPython implementation (limited features) | +| **JavaScript** | `src/natsbridge.js` | Node.js/browser implementation | +| **Python** | `src/natsbridge.py` | Desktop Python implementation | +| **MicroPython** | `src/natsbridge_mpy.py` | MicroPython implementation (limited features) | --- @@ -228,7 +228,7 @@ end #### JavaScript ```javascript -const NATSBridge = require('natbridge'); +const NATSBridge = require('natsbridge'); // Single payload const [env, env_json_str] = await NATSBridge.smartsend( @@ -275,7 +275,7 @@ for (const [dataname, data, type] of env.payloads) { #### Python ```python -from natbridge import NATSBridge +from natsbridge import NATSBridge # Single payload env, env_json_str = await NATSBridge.smartsend( @@ -317,7 +317,7 @@ for dataname, data, type_ in env["payloads"]: #### MicroPython ```python -from natbridge import NATSBridge +from natsbridge import NATSBridge # Limited to text and binary (no tables due to memory constraints) env, env_json_str = NATSBridge.smartsend( @@ -929,7 +929,7 @@ end #### Module Structure ```javascript -// natbridge.js +// natsbridge.js const nats = require('nats'); const { v4: uuidv4 } = require('uuid'); const fetch = require('node-fetch'); @@ -1272,7 +1272,7 @@ async function plikOneshotUpload(file_server_url, dataname, data) { #### Module Structure ```python -# natbridge.py +# natsbridge.py import asyncio import base64 import json @@ -1690,7 +1690,7 @@ MicroPython has significant constraints compared to desktop implementations: ### MicroPython Module Structure ```python -# natbridge_mpy.py (MicroPython) +# natsbridge_mpy.py (MicroPython) import network import time import json diff --git a/examples/tutorial.md b/examples/tutorial.md index 0969849..b43715d 100644 --- a/examples/tutorial.md +++ b/examples/tutorial.md @@ -134,7 +134,7 @@ env, env_json_str = smartsend("/chat/room1", data, broker_url="nats://localhost: #### JavaScript ```javascript -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); // Send a text message const data = [["message", "Hello World", "text"]]; @@ -158,7 +158,7 @@ const [env, env_json_str] = await NATSBridge.smartsend( #### Python ```python -from natbridge import smartsend +from natsbridge import smartsend # Send a text message data = [("message", "Hello World", "text")] @@ -185,7 +185,7 @@ env, env_json_str = await smartsend( #### MicroPython ```python -from natbridge_mpy import NATSBridge +from natsbridge_mpy import NATSBridge bridge = NATSBridge() @@ -218,7 +218,7 @@ end #### JavaScript ```javascript -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); // Receive and process message const env = await NATSBridge.smartreceive(msg, { @@ -233,7 +233,7 @@ for (const [dataname, data, type] of env.payloads) { #### Python ```python -from natbridge import smartreceive, fetch_with_backoff +from natsbridge import smartreceive, fetch_with_backoff # Receive and process message env = await smartreceive( @@ -269,7 +269,7 @@ env, env_json_str = smartsend("/device/config", data, broker_url="nats://localho #### JavaScript ```javascript -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); const config = { wifi_ssid: "MyNetwork", @@ -288,7 +288,7 @@ const [env, env_json_str] = await NATSBridge.smartsend( #### Python ```python -from natbridge import smartsend +from natsbridge import smartsend config = { "wifi_ssid": "MyNetwork", @@ -307,7 +307,7 @@ env, env_json_str = await smartsend( #### MicroPython ```python -from natbridge_mpy import NATSBridge +from natsbridge_mpy import NATSBridge bridge = NATSBridge() @@ -342,7 +342,7 @@ env, env_json_str = smartsend("/chat/image", data, broker_url="nats://localhost: #### JavaScript ```javascript -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); const fs = require('fs'); // Read image file @@ -359,7 +359,7 @@ const [env, env_json_str] = await NATSBridge.smartsend( #### Python ```python -from natbridge import smartsend +from natsbridge import smartsend # Read image file with open("image.png", "rb") as f: @@ -376,7 +376,7 @@ env, env_json_str = await smartsend( #### MicroPython ```python -from natbridge_mpy import NATSBridge +from natsbridge_mpy import NATSBridge bridge = NATSBridge() @@ -413,7 +413,7 @@ env, env_json_str = smartsend( #### JavaScript (Requester) ```javascript -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); // Send command with reply-to const data = [["command", { action: "read_sensor" }, "dictionary"]]; @@ -431,7 +431,7 @@ const [env, env_json_str] = await NATSBridge.smartsend( #### Python (Requester) ```python -from natbridge import smartsend +from natsbridge import smartsend # Send command with reply-to data = [("command", {"action": "read_sensor"}, "dictionary")] @@ -506,7 +506,7 @@ println("File uploaded to: $(env.payloads[1].data)") #### JavaScript ```javascript -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); // Create large data (> 1MB) const large_data = Buffer.alloc(2_000_000); @@ -530,7 +530,7 @@ console.log("File uploaded to:", env.payloads[0].data); #### Python ```python -from natbridge import smartsend +from natsbridge import smartsend # Create large data (> 1MB) import os @@ -552,7 +552,7 @@ print(f"File uploaded to: {env['payloads'][0]['data']}") MicroPython enforces a hard limit of 50KB per payload: ```python -from natbridge_mpy import NATSBridge +from natsbridge_mpy import NATSBridge bridge = NATSBridge() @@ -590,7 +590,7 @@ env, env_json_str = smartsend("/chat/mixed", data, broker_url="nats://localhost: #### JavaScript ```javascript -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); const fs = require('fs'); const image_data = fs.readFileSync('avatar.png'); @@ -610,7 +610,7 @@ const [env, env_json_str] = await NATSBridge.smartsend( #### Python ```python -from natbridge import smartsend +from natsbridge import smartsend with open("avatar.png", "rb") as f: image_data = f.read() @@ -652,7 +652,7 @@ env, env_json_str = smartsend("/data/students", data, broker_url="nats://localho #### JavaScript ```javascript -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); // Create table data (array of objects) const table_data = [ @@ -672,7 +672,7 @@ const [env, env_json_str] = await NATSBridge.smartsend( #### Python ```python -from natbridge import smartsend +from natsbridge import smartsend import pandas as pd # Create DataFrame diff --git a/examples/walkthrough.md b/examples/walkthrough.md index a8d8efc..28cb59f 100644 --- a/examples/walkthrough.md +++ b/examples/walkthrough.md @@ -177,7 +177,7 @@ end ```javascript // src/chat_ui.js -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); class ChatUI { constructor() { @@ -333,7 +333,7 @@ end ```javascript // src/chat_handler.js -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); const nats = require('nats'); class ChatHandler { @@ -393,7 +393,7 @@ module.exports = ChatHandler; # src/chat_handler.py import asyncio from typing import Optional -from natbridge import smartreceive, fetch_with_backoff +from natsbridge import smartreceive, fetch_with_backoff class ChatHandler: def __init__(self, nats_connection): @@ -526,7 +526,7 @@ end ```javascript // src/file_upload_service.js -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); const fs = require('fs'); class FileUploadService { @@ -580,7 +580,7 @@ module.exports = FileUploadService; ```python # src/file_upload_service.py -from natbridge import smartsend +from natsbridge import smartsend import os class FileUploadService: @@ -659,7 +659,7 @@ end ```javascript // src/file_download_service.js -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); const fs = require('fs'); class FileDownloadService { @@ -690,7 +690,7 @@ module.exports = FileDownloadService; ```python # src/file_download_service.py -from natbridge import smartreceive, fetch_with_backoff +from natsbridge import smartreceive, fetch_with_backoff import os class FileDownloadService: @@ -832,7 +832,7 @@ end ```javascript // src/sensor_data.js -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); class SensorReading { constructor(sensorId, value, unit, metadata = {}) { @@ -985,7 +985,7 @@ end ```javascript // src/sensor_sender.js -const NATSBridge = require('./src/natbridge.js'); +const NATSBridge = require('./src/natsbridge.js'); const { SensorReading, SensorBatch } = require('./sensor_data.js'); class SensorSender { @@ -1069,7 +1069,7 @@ module.exports = SensorSender; ```python # src/sensor_sender.py -from natbridge import smartsend +from natsbridge import smartsend from sensor_data import SensorReading, SensorBatch class SensorSender: @@ -1282,7 +1282,7 @@ end # Cache file server responses import asyncio import threading -from natbridge import fetch_with_backoff +from natsbridge import fetch_with_backoff file_cache = {} cache_lock = threading.Lock() diff --git a/src/natbridge.js b/src/natsbridge.js similarity index 100% rename from src/natbridge.js rename to src/natsbridge.js diff --git a/src/natbridge.py b/src/natsbridge.py similarity index 99% rename from src/natbridge.py rename to src/natsbridge.py index ee94bb0..f30851d 100644 --- a/src/natbridge.py +++ b/src/natsbridge.py @@ -6,7 +6,7 @@ This module provides functionality for sending and receiving data across network using NATS as the message bus, with support for both direct payload transport and URL-based transport for larger payloads. -@package natbridge +@package natsbridge """ import asyncio diff --git a/src/natbridge_mpy.py b/src/natsbridge_mpy.py similarity index 100% rename from src/natbridge_mpy.py rename to src/natsbridge_mpy.py diff --git a/test/test_js_binary_receiver.js b/test/test_js_binary_receiver.js index 1d989f6..db8f5f0 100644 --- a/test/test_js_binary_receiver.js +++ b/test/test_js_binary_receiver.js @@ -3,7 +3,7 @@ * Tests the smartreceive function with binary/image/audio/video payloads */ -const NATSBridge = require('../src/natbridge.js'); +const NATSBridge = require('../src/natsbridge.js'); const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222'; const TEST_FILESERVER_URL = process.env.FILESERVER_URL || 'http://localhost:8080'; diff --git a/test/test_js_binary_sender.js b/test/test_js_binary_sender.js index 4562d53..dea75fb 100644 --- a/test/test_js_binary_sender.js +++ b/test/test_js_binary_sender.js @@ -3,7 +3,7 @@ * Tests the smartsend function with binary/image/audio/video payloads */ -const NATSBridge = require('../src/natbridge.js'); +const NATSBridge = require('../src/natsbridge.js'); const TEST_SUBJECT = '/test/binary'; const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222'; diff --git a/test/test_js_dictionary_receiver.js b/test/test_js_dictionary_receiver.js index 1011fdf..e18d57b 100644 --- a/test/test_js_dictionary_receiver.js +++ b/test/test_js_dictionary_receiver.js @@ -3,7 +3,7 @@ * Tests the smartreceive function with dictionary payloads */ -const NATSBridge = require('../src/natbridge.js'); +const NATSBridge = require('../src/natsbridge.js'); const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222'; const TEST_FILESERVER_URL = process.env.FILESERVER_URL || 'http://localhost:8080'; diff --git a/test/test_js_dictionary_sender.js b/test/test_js_dictionary_sender.js index d3acca3..e0eef78 100644 --- a/test/test_js_dictionary_sender.js +++ b/test/test_js_dictionary_sender.js @@ -3,7 +3,7 @@ * Tests the smartsend function with dictionary payloads */ -const NATSBridge = require('../src/natbridge.js'); +const NATSBridge = require('../src/natsbridge.js'); const TEST_SUBJECT = '/test/dictionary'; const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222'; diff --git a/test/test_js_mix_payloads_sender.js b/test/test_js_mix_payloads_sender.js index 6a25b55..534fe5c 100644 --- a/test/test_js_mix_payloads_sender.js +++ b/test/test_js_mix_payloads_sender.js @@ -3,7 +3,7 @@ * Tests the smartsend function with mixed payload types */ -const NATSBridge = require('../src/natbridge.js'); +const NATSBridge = require('../src/natsbridge.js'); const TEST_SUBJECT = '/test/mix'; const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222'; diff --git a/test/test_js_table_receiver.js b/test/test_js_table_receiver.js index d73eae1..ec99ec4 100644 --- a/test/test_js_table_receiver.js +++ b/test/test_js_table_receiver.js @@ -3,7 +3,7 @@ * Tests the smartreceive function with table (Arrow IPC) payloads */ -const NATSBridge = require('../src/natbridge.js'); +const NATSBridge = require('../src/natsbridge.js'); const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222'; const TEST_FILESERVER_URL = process.env.FILESERVER_URL || 'http://localhost:8080'; diff --git a/test/test_js_table_sender.js b/test/test_js_table_sender.js index 7f8fa21..f95512c 100644 --- a/test/test_js_table_sender.js +++ b/test/test_js_table_sender.js @@ -3,7 +3,7 @@ * Tests the smartsend function with table (Arrow IPC) payloads */ -const NATSBridge = require('../src/natbridge.js'); +const NATSBridge = require('../src/natsbridge.js'); const TEST_SUBJECT = '/test/table'; const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222'; diff --git a/test/test_js_text_receiver.js b/test/test_js_text_receiver.js index 479ece5..54a6b37 100644 --- a/test/test_js_text_receiver.js +++ b/test/test_js_text_receiver.js @@ -3,7 +3,7 @@ * Tests the smartreceive function with text payloads */ -const NATSBridge = require('../src/natbridge.js'); +const NATSBridge = require('../src/natsbridge.js'); const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222'; const TEST_FILESERVER_URL = process.env.FILESERVER_URL || 'http://localhost:8080'; diff --git a/test/test_js_text_sender.js b/test/test_js_text_sender.js index dda7b0c..3bcd013 100644 --- a/test/test_js_text_sender.js +++ b/test/test_js_text_sender.js @@ -3,7 +3,7 @@ * Tests the smartsend function with text payloads */ -const NATSBridge = require('../src/natbridge.js'); +const NATSBridge = require('../src/natsbridge.js'); const TEST_SUBJECT = '/test/text'; const TEST_BROKER_URL = process.env.NATS_URL || 'nats://localhost:4222'; diff --git a/test/test_mpy_binary_receiver.py b/test/test_mpy_binary_receiver.py index 09bf589..13f6da5 100644 --- a/test/test_mpy_binary_receiver.py +++ b/test/test_mpy_binary_receiver.py @@ -14,7 +14,7 @@ import base64 # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL +from natsbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') @@ -23,7 +23,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') def run_test(): print('=== MicroPython Binary Receiver Test ===\n') - from natbridge_mpy import _generate_uuid + from natsbridge_mpy import _generate_uuid # Create mock NATS message with binary payloads image_data = bytes([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]) # PNG header diff --git a/test/test_mpy_binary_sender.py b/test/test_mpy_binary_sender.py index 45a6e00..bd44fb8 100644 --- a/test/test_mpy_binary_sender.py +++ b/test/test_mpy_binary_sender.py @@ -13,7 +13,7 @@ import base64 # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE +from natsbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE TEST_SUBJECT = '/test/binary' TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') @@ -23,7 +23,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') def run_test(): print('=== MicroPython Binary Sender Test ===\n') - from natbridge_mpy import _generate_uuid + from natsbridge_mpy import _generate_uuid correlation_id = 'mpy-binary-test-' + _generate_uuid() print(f'Correlation ID: {correlation_id}') print(f'Subject: {TEST_SUBJECT}') diff --git a/test/test_mpy_dictionary_receiver.py b/test/test_mpy_dictionary_receiver.py index 5f431a0..0f3a804 100644 --- a/test/test_mpy_dictionary_receiver.py +++ b/test/test_mpy_dictionary_receiver.py @@ -13,7 +13,7 @@ import json # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL +from natsbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') @@ -22,7 +22,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') def run_test(): print('=== MicroPython Dictionary Receiver Test ===\n') - from natbridge_mpy import _generate_uuid + from natsbridge_mpy import _generate_uuid # Create a mock NATS message with dictionary payloads import base64 diff --git a/test/test_mpy_dictionary_sender.py b/test/test_mpy_dictionary_sender.py index 33aa92a..54a190d 100644 --- a/test/test_mpy_dictionary_sender.py +++ b/test/test_mpy_dictionary_sender.py @@ -13,7 +13,7 @@ import json # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE +from natsbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE TEST_SUBJECT = '/test/dictionary' TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') @@ -23,7 +23,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') def run_test(): print('=== MicroPython Dictionary Sender Test ===\n') - from natbridge_mpy import _generate_uuid + from natsbridge_mpy import _generate_uuid correlation_id = 'mpy-dict-test-' + _generate_uuid() print(f'Correlation ID: {correlation_id}') print(f'Subject: {TEST_SUBJECT}') diff --git a/test/test_mpy_text_receiver.py b/test/test_mpy_text_receiver.py index c224d05..c053a0b 100644 --- a/test/test_mpy_text_receiver.py +++ b/test/test_mpy_text_receiver.py @@ -13,7 +13,7 @@ import json # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL +from natsbridge_mpy import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') @@ -22,7 +22,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') def run_test(): print('=== MicroPython Text Receiver Test ===\n') - from natbridge_mpy import _generate_uuid + from natsbridge_mpy import _generate_uuid # Create a mock NATS message with text payload test_text = 'Hello, NATSBridge! This is a test message.' diff --git a/test/test_mpy_text_sender.py b/test/test_mpy_text_sender.py index f52fd4f..dff9ec8 100644 --- a/test/test_mpy_text_sender.py +++ b/test/test_mpy_text_sender.py @@ -12,7 +12,7 @@ import os # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE +from natsbridge_mpy import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL, DEFAULT_SIZE_THRESHOLD, MAX_PAYLOAD_SIZE TEST_SUBJECT = '/test/text' TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') @@ -22,7 +22,7 @@ TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') def run_test(): print('=== MicroPython Text Sender Test ===\n') - from natbridge_mpy import _generate_uuid + from natsbridge_mpy import _generate_uuid correlation_id = 'mpy-text-test-' + _generate_uuid() print(f'Correlation ID: {correlation_id}') print(f'Subject: {TEST_SUBJECT}') diff --git a/test/test_py_binary_receiver.py b/test/test_py_binary_receiver.py index d1410b0..eaeeb0c 100644 --- a/test/test_py_binary_receiver.py +++ b/test/test_py_binary_receiver.py @@ -12,7 +12,7 @@ import base64 # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL +from natsbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') diff --git a/test/test_py_binary_sender.py b/test/test_py_binary_sender.py index 2de616d..74de656 100644 --- a/test/test_py_binary_sender.py +++ b/test/test_py_binary_sender.py @@ -11,7 +11,7 @@ import base64 # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL +from natsbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL TEST_SUBJECT = '/test/binary' TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') diff --git a/test/test_py_dictionary_receiver.py b/test/test_py_dictionary_receiver.py index f6afb16..293b3cb 100644 --- a/test/test_py_dictionary_receiver.py +++ b/test/test_py_dictionary_receiver.py @@ -11,7 +11,7 @@ import json # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL +from natsbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') diff --git a/test/test_py_dictionary_sender.py b/test/test_py_dictionary_sender.py index 908c2e7..b8027cc 100644 --- a/test/test_py_dictionary_sender.py +++ b/test/test_py_dictionary_sender.py @@ -11,7 +11,7 @@ import json # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL +from natsbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL TEST_SUBJECT = '/test/dictionary' TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') diff --git a/test/test_py_mix_payloads_sender.py b/test/test_py_mix_payloads_sender.py index 3a95e0c..7f9d858 100644 --- a/test/test_py_mix_payloads_sender.py +++ b/test/test_py_mix_payloads_sender.py @@ -11,7 +11,7 @@ import base64 # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL +from natsbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL TEST_SUBJECT = '/test/mix' TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') diff --git a/test/test_py_table_sender.py b/test/test_py_table_sender.py index 1c04eb0..724260b 100644 --- a/test/test_py_table_sender.py +++ b/test/test_py_table_sender.py @@ -10,7 +10,7 @@ import os # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL +from natsbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL TEST_SUBJECT = '/test/table' TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') diff --git a/test/test_py_text_receiver.py b/test/test_py_text_receiver.py index 6758d8b..c22493f 100644 --- a/test/test_py_text_receiver.py +++ b/test/test_py_text_receiver.py @@ -11,7 +11,7 @@ import json # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL +from natsbridge import smartreceive, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222') TEST_FILESERVER_URL = os.environ.get('FILESERVER_URL', 'http://localhost:8080') diff --git a/test/test_py_text_sender.py b/test/test_py_text_sender.py index d1fa716..ac86044 100644 --- a/test/test_py_text_sender.py +++ b/test/test_py_text_sender.py @@ -10,7 +10,7 @@ import os # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from natbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL +from natsbridge import smartsend, DEFAULT_BROKER_URL, DEFAULT_FILESERVER_URL TEST_SUBJECT = '/test/text' TEST_BROKER_URL = os.environ.get('NATS_URL', 'nats://localhost:4222')