diff --git a/CMakeLists.txt b/CMakeLists.txt index 7206e48..9570ea2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ # Top-level build for PyFlow. # # All CMake content lives here at the repository root: the crypto_api C -# library (sources under PyFlow/crypto_api, C tests under test/) plus its -# install/export rules. The Python package is managed by uv/pytest instead. +# library (sources under PyFlow/crypto_api, C tests under test/crypto_api) +# plus its install/export rules. The Python package is managed by uv/pytest instead. cmake_minimum_required(VERSION 3.16) project(pyflow VERSION 0.1.0 LANGUAGES C) @@ -90,10 +90,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/crypto_api.pc.in install(FILES ${CMAKE_CURRENT_BINARY_DIR}/crypto_api.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -# ---- C tests (sources in test/) ------------------------------------------- +# ---- C tests (sources in test/crypto_api) --------------------------------- if(CRYPTO_API_BUILD_TESTS AND BUILD_TESTING) foreach(test_name IN ITEMS test_hkdf test_rsa test_ecdh) - add_executable(${test_name} test/${test_name}.c) + add_executable(${test_name} test/crypto_api/${test_name}.c) target_link_libraries(${test_name} PRIVATE crypto_api) target_compile_options(${test_name} PRIVATE -Wall -Wextra) add_test(NAME ${test_name} COMMAND ${test_name}) diff --git a/README.md b/README.md index 2890584..608101e 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ PyFlow/ ├── __init__.py / __main__.py package launcher entry (`python -m PyFlow`) ├── flow_setup.py launcher implementation └── setup.json default launcher configuration (generated) -test/ C tests (test_hkdf/test_rsa/test_ecdh) + Python tests +test/ Python tests (unit/ + integration/), C tests under test/crypto_api/ docs/ Sphinx documentation (multi-language) CMakeLists.txt top-level build for the C library and C tests ``` @@ -166,7 +166,7 @@ uv run pytest # full Python suite ctest --test-dir build # C library tests ``` -The encrypted-channel tests (`test/test_crypto_rsa.py`, `test/test_crypto_tcp.py`) are skipped automatically when `libcrypto_api` has not been built; everything else runs regardless. The suite passes on Python 3.10–3.14, including the free-threaded (no-GIL) 3.14 build. +The encrypted-channel tests (`test/unit/network_api/test_crypto_rsa.py`, `test/integration/network_api/test_crypto_tcp.py`) are skipped automatically when `libcrypto_api` has not been built; everything else runs regardless. The suite passes on Python 3.10–3.14, including the free-threaded (no-GIL) 3.14 build. ## Documentation diff --git a/docs/Crypto/Crypto.rst b/docs/Crypto/Crypto.rst index e643e09..744462e 100644 --- a/docs/Crypto/Crypto.rst +++ b/docs/Crypto/Crypto.rst @@ -38,7 +38,7 @@ Build it from the repository root: cmake --build build --parallel ctest --test-dir build --output-on-failure -The C test suite lives in ``test/`` (``test_hkdf``, ``test_rsa``, +The C test suite lives in ``test/crypto_api/`` (``test_hkdf``, ``test_rsa``, ``test_ecdh``) and is built and run together with the library. The library is built as a shared object (``libcrypto_api.so``) so it can diff --git a/docs/locale/ja/LC_MESSAGES/Crypto/Crypto.po b/docs/locale/ja/LC_MESSAGES/Crypto/Crypto.po index fb18ee3..3943cde 100644 --- a/docs/locale/ja/LC_MESSAGES/Crypto/Crypto.po +++ b/docs/locale/ja/LC_MESSAGES/Crypto/Crypto.po @@ -91,12 +91,12 @@ msgstr "" msgid "Build it from the repository root:" msgstr "リポジトリのルートからビルドします。" -#: ../../Crypto/Crypto.rst:41 04d983635b00498a8ec2d1844472d78e +#: ../../Crypto/Crypto.rst:41 7ff0eaa67fde42f8a90908d100eda4fa msgid "" -"The C test suite lives in ``test/`` (``test_hkdf``, ``test_rsa``, " +"The C test suite lives in ``test/crypto_api/`` (``test_hkdf``, ``test_rsa``, " "``test_ecdh``) and is built and run together with the library." msgstr "" -"C テストスイートは ``test/`` (``test_hkdf``、``test_rsa``、``test_ecdh``) " +"C テストスイートは ``test/crypto_api/`` (``test_hkdf``、``test_rsa``、``test_ecdh``) " "に存在し、ライブラリと一緒に構築および実行されます。" #: ../../Crypto/Crypto.rst:44 2d8ebac8b06147e4983c07a6c69296ab diff --git a/docs/locale/ko/LC_MESSAGES/Crypto/Crypto.po b/docs/locale/ko/LC_MESSAGES/Crypto/Crypto.po index 4489976..8118474 100644 --- a/docs/locale/ko/LC_MESSAGES/Crypto/Crypto.po +++ b/docs/locale/ko/LC_MESSAGES/Crypto/Crypto.po @@ -91,12 +91,12 @@ msgstr "" msgid "Build it from the repository root:" msgstr "저장소 루트에서 빌드합니다." -#: ../../Crypto/Crypto.rst:41 04d983635b00498a8ec2d1844472d78e +#: ../../Crypto/Crypto.rst:41 7ff0eaa67fde42f8a90908d100eda4fa msgid "" -"The C test suite lives in ``test/`` (``test_hkdf``, ``test_rsa``, " +"The C test suite lives in ``test/crypto_api/`` (``test_hkdf``, ``test_rsa``, " "``test_ecdh``) and is built and run together with the library." msgstr "" -"C 테스트 스위트는 ``test/``(``test_hkdf``, ``test_rsa``, ``test_ecdh``)에 있으며 라이브러리와" +"C 테스트 스위트는 ``test/crypto_api/``(``test_hkdf``, ``test_rsa``, ``test_ecdh``)에 있으며 라이브러리와" " 함께 빌드되고 실행됩니다." #: ../../Crypto/Crypto.rst:44 2d8ebac8b06147e4983c07a6c69296ab diff --git a/docs/locale/ru/LC_MESSAGES/Crypto/Crypto.po b/docs/locale/ru/LC_MESSAGES/Crypto/Crypto.po index 34b1a9f..50e75bf 100644 --- a/docs/locale/ru/LC_MESSAGES/Crypto/Crypto.po +++ b/docs/locale/ru/LC_MESSAGES/Crypto/Crypto.po @@ -94,12 +94,12 @@ msgstr "" msgid "Build it from the repository root:" msgstr "Соберите его из корня репозитория:" -#: ../../Crypto/Crypto.rst:41 04d983635b00498a8ec2d1844472d78e +#: ../../Crypto/Crypto.rst:41 7ff0eaa67fde42f8a90908d100eda4fa msgid "" -"The C test suite lives in ``test/`` (``test_hkdf``, ``test_rsa``, " +"The C test suite lives in ``test/crypto_api/`` (``test_hkdf``, ``test_rsa``, " "``test_ecdh``) and is built and run together with the library." msgstr "" -"Набор тестов C находится в ``test/`` (``test_hkdf``, ``test_rsa``, " +"Набор тестов C находится в ``test/crypto_api/`` (``test_hkdf``, ``test_rsa``, " "``test_ecdh``) и собирается и запускается вместе с библиотекой." #: ../../Crypto/Crypto.rst:44 2d8ebac8b06147e4983c07a6c69296ab diff --git a/docs/locale/zh_CN/LC_MESSAGES/Crypto/Crypto.po b/docs/locale/zh_CN/LC_MESSAGES/Crypto/Crypto.po index 80a9637..40eae61 100644 --- a/docs/locale/zh_CN/LC_MESSAGES/Crypto/Crypto.po +++ b/docs/locale/zh_CN/LC_MESSAGES/Crypto/Crypto.po @@ -91,11 +91,11 @@ msgstr "" msgid "Build it from the repository root:" msgstr "从存储库根目录构建它:" -#: ../../Crypto/Crypto.rst:41 04d983635b00498a8ec2d1844472d78e +#: ../../Crypto/Crypto.rst:41 7ff0eaa67fde42f8a90908d100eda4fa msgid "" -"The C test suite lives in ``test/`` (``test_hkdf``, ``test_rsa``, " +"The C test suite lives in ``test/crypto_api/`` (``test_hkdf``, ``test_rsa``, " "``test_ecdh``) and is built and run together with the library." -msgstr "C 测试套件位于“test/”(“test_hkdf”、“test_rsa”、“test_ecdh”)中,并与库一起构建和运行。" +msgstr "C 测试套件位于“test/crypto_api/”(“test_hkdf”、“test_rsa”、“test_ecdh”)中,并与库一起构建和运行。" #: ../../Crypto/Crypto.rst:44 2d8ebac8b06147e4983c07a6c69296ab #, fuzzy diff --git a/docs/locale/zh_TW/LC_MESSAGES/Crypto/Crypto.po b/docs/locale/zh_TW/LC_MESSAGES/Crypto/Crypto.po index 42cd9cf..36cd832 100644 --- a/docs/locale/zh_TW/LC_MESSAGES/Crypto/Crypto.po +++ b/docs/locale/zh_TW/LC_MESSAGES/Crypto/Crypto.po @@ -91,11 +91,11 @@ msgstr "" msgid "Build it from the repository root:" msgstr "從儲存庫根目錄建立它:" -#: ../../Crypto/Crypto.rst:41 04d983635b00498a8ec2d1844472d78e +#: ../../Crypto/Crypto.rst:41 7ff0eaa67fde42f8a90908d100eda4fa msgid "" -"The C test suite lives in ``test/`` (``test_hkdf``, ``test_rsa``, " +"The C test suite lives in ``test/crypto_api/`` (``test_hkdf``, ``test_rsa``, " "``test_ecdh``) and is built and run together with the library." -msgstr "C 測試套件位於“test/”(“test_hkdf”、“test_rsa”、“test_ecdh”)中,並與程式庫一起建置和運行。" +msgstr "C 測試套件位於“test/crypto_api/”(“test_hkdf”、“test_rsa”、“test_ecdh”)中,並與程式庫一起建置和運行。" #: ../../Crypto/Crypto.rst:44 2d8ebac8b06147e4983c07a6c69296ab #, fuzzy diff --git a/pyproject.toml b/pyproject.toml index de0ac56..370415b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,4 +66,3 @@ exclude = ["test/"] [tool.pytest.ini_options] testpaths = ["test"] -addopts = "--ignore=test/test_instance_setup" diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..5a51a6a --- /dev/null +++ b/test/README.md @@ -0,0 +1,26 @@ +# Test layout + +Tests are split first by the real dependencies they touch, then mirrored +against the package layout one level deep: `PyFlow//` maps to +`test///`, and root-level modules map to the tier root. A new +subdirectory appears only when the source gains the matching package. + +``` +test/ +├── unit/ no network I/O, no subprocesses +│ ├── test_flow_setup.py launcher logic with mocked Popen (PyFlow/flow_setup.py) +│ └── network_api/ object construction, pure logic, real crypto without sockets +├── integration/ real sockets, but server + client live in the test process +│ ├── conftest.py shared server/client/udp fixtures +│ ├── helpers.py wait_until / server_ready polling helpers +│ ├── test_forward_extension.py, test_command_handlers.py, ... +│ │ extension modules at the PyFlow package root +│ └── network_api/ encrypted channel, file transfer, udp, event store, ... +└── crypto_api/ C library tests (CMake/ctest, not pytest), mirroring PyFlow/crypto_api +``` + +The tree is illustrative, not an inventory — it shows the pattern, not +every file. + +- **unit** may load the real crypto library through ctypes; that is not + network I/O even though it pulls in a shared object. \ No newline at end of file diff --git a/test/test_util.h b/test/crypto_api/helpers.h similarity index 96% rename from test/test_util.h rename to test/crypto_api/helpers.h index 08fd868..f69c493 100644 --- a/test/test_util.h +++ b/test/crypto_api/helpers.h @@ -1,6 +1,6 @@ /* Shared test harness: check macros with failure accounting. */ -#ifndef PF_CRYPTO_TEST_UTIL_H -#define PF_CRYPTO_TEST_UTIL_H +#ifndef PF_CRYPTO_HELPERS_H +#define PF_CRYPTO_HELPERS_H #include #include @@ -42,4 +42,4 @@ static int g_failures = 0; return 1; \ } -#endif /* PF_CRYPTO_TEST_UTIL_H */ +#endif /* PF_CRYPTO_HELPERS_H */ diff --git a/test/test_ecdh.c b/test/crypto_api/test_ecdh.c similarity index 99% rename from test/test_ecdh.c rename to test/crypto_api/test_ecdh.c index e71210b..13fddfa 100644 --- a/test/test_ecdh.c +++ b/test/crypto_api/test_ecdh.c @@ -6,7 +6,7 @@ #include #include -#include "test_util.h" +#include "helpers.h" #define PRIV_A_FILE "test_ecdh_a_priv.pem" #define PASSPHRASE "ecdh passphrase" diff --git a/test/test_hkdf.c b/test/crypto_api/test_hkdf.c similarity index 99% rename from test/test_hkdf.c rename to test/crypto_api/test_hkdf.c index d0142e1..d2ec50d 100644 --- a/test/test_hkdf.c +++ b/test/crypto_api/test_hkdf.c @@ -5,7 +5,7 @@ #include #include -#include "test_util.h" +#include "helpers.h" /* Hex string -> bytes; returns byte count or -1 on error. */ static int hex2bin(const char *hex, uint8_t *out, size_t out_cap) { diff --git a/test/test_rsa.c b/test/crypto_api/test_rsa.c similarity index 99% rename from test/test_rsa.c rename to test/crypto_api/test_rsa.c index 9ad99c9..c9f85b8 100644 --- a/test/test_rsa.c +++ b/test/crypto_api/test_rsa.c @@ -5,7 +5,7 @@ #include #include -#include "test_util.h" +#include "helpers.h" #define PUB_FILE "test_rsa_pub.pem" #define PRIV_FILE "test_rsa_priv.pem" diff --git a/test/conftest.py b/test/integration/conftest.py similarity index 89% rename from test/conftest.py rename to test/integration/conftest.py index 77fa1f9..0f8eeca 100644 --- a/test/conftest.py +++ b/test/integration/conftest.py @@ -1,13 +1,5 @@ -import importlib.util -import os -import sys - import pytest -# Only add project root to sys.path if the PyFlow package is not importable -if importlib.util.find_spec("PyFlow") is None: - sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - import PyFlow.command_control_extension_tcp as ctl from PyFlow.network_api.connect_tcp import TCP_Client_Base, TCP_Server_Base from PyFlow.network_api.connect_udp import UDP diff --git a/test/test_util.py b/test/integration/helpers.py similarity index 65% rename from test/test_util.py rename to test/integration/helpers.py index b57a6f0..6ef2b91 100644 --- a/test/test_util.py +++ b/test/integration/helpers.py @@ -1,4 +1,4 @@ -"""Shared helpers for tests.""" +"""Shared helpers for the integration tests.""" import time @@ -15,9 +15,4 @@ def wait_until(predicate, timeout=5.0, interval=0.05): def server_ready(server, timeout=5.0): """Wait until a TCP server is running.""" - deadline = time.monotonic() + timeout - while time.monotonic() < deadline: - if server.running: - return True - time.sleep(0.05) - return False + return wait_until(lambda: server.running, timeout=timeout) \ No newline at end of file diff --git a/test/test_crypto_tcp.py b/test/integration/network_api/test_crypto_tcp.py similarity index 98% rename from test/test_crypto_tcp.py rename to test/integration/network_api/test_crypto_tcp.py index 6dac264..df35664 100644 --- a/test/test_crypto_tcp.py +++ b/test/integration/network_api/test_crypto_tcp.py @@ -1,4 +1,4 @@ -"""End-to-end tests for RSA-encrypted TCP channels (connect_tcp.py). +"""Integration tests for RSA-encrypted TCP channels (connect_tcp.py). A real server and client are connected over loopback with the crypto key directories redirected to a temporary location. These tests need the @@ -15,7 +15,7 @@ import pytest -from test_util import server_ready, wait_until +from helpers import server_ready, wait_until from PyFlow.network_api import rsa_crypto from PyFlow.network_api.connect_tcp import TCP_Client_Base, TCP_Server_Base @@ -554,12 +554,8 @@ def test_concurrent_clients_share_key_exchange(tmp_path): is_enable_encrypto=True, ) _redirect_crypto(server.crypto, tmp_path, ssh_dir, "pub_key") - recv_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.abspath(__file__))), - "PyFlow", - "network_api", - "received_files", - ) + recv_dir = server.file_transfer_dir + os.makedirs(recv_dir, exist_ok=True) # a failed earlier run may have left stale key files behind; the # assertion below checks this run leaves nothing behind, so start clean for leftover_name in os.listdir(recv_dir): diff --git a/test/test_message_event_store.py b/test/integration/network_api/test_message_event_store.py similarity index 99% rename from test/test_message_event_store.py rename to test/integration/network_api/test_message_event_store.py index 7afed24..d4ca800 100644 --- a/test/test_message_event_store.py +++ b/test/integration/network_api/test_message_event_store.py @@ -13,7 +13,7 @@ import pytest -from test_util import server_ready, wait_until +from helpers import server_ready, wait_until from PyFlow.network_api.connect_tcp import TCP_Client_Base, TCP_Server_Base diff --git a/test/test_tcp_broadcast_alloc.py b/test/integration/network_api/test_tcp_broadcast_alloc.py similarity index 100% rename from test/test_tcp_broadcast_alloc.py rename to test/integration/network_api/test_tcp_broadcast_alloc.py diff --git a/test/test_tcp_file_transfer.py b/test/integration/network_api/test_tcp_file_transfer.py similarity index 99% rename from test/test_tcp_file_transfer.py rename to test/integration/network_api/test_tcp_file_transfer.py index 612708f..c0aabb9 100644 --- a/test/test_tcp_file_transfer.py +++ b/test/integration/network_api/test_tcp_file_transfer.py @@ -1,4 +1,4 @@ -"""End-to-end file-transfer tests (plain channel, no crypto).""" +"""Integration tests for file transfer (plain channel, no crypto).""" import os import threading @@ -8,7 +8,7 @@ import pytest -from test_util import server_ready, wait_until +from helpers import server_ready, wait_until from PyFlow.network_api.connect_tcp import ( TCP_Client_Base, diff --git a/test/test_udp.py b/test/integration/network_api/test_udp.py similarity index 100% rename from test/test_udp.py rename to test/integration/network_api/test_udp.py diff --git a/test/test_command_handlers.py b/test/integration/test_command_handlers.py similarity index 100% rename from test/test_command_handlers.py rename to test/integration/test_command_handlers.py diff --git a/test/test_extension_TCP_setup.py b/test/integration/test_extension_TCP_setup.py similarity index 100% rename from test/test_extension_TCP_setup.py rename to test/integration/test_extension_TCP_setup.py diff --git a/test/test_forward_extension.py b/test/integration/test_forward_extension.py similarity index 99% rename from test/test_forward_extension.py rename to test/integration/test_forward_extension.py index 22c95cf..03046b9 100644 --- a/test/test_forward_extension.py +++ b/test/integration/test_forward_extension.py @@ -246,7 +246,7 @@ def fake_server(**kwargs): def test_server_dispatches_forward_send_msg_internally(server, capsys): """/forward_send_msg arriving over the wire is routed by handle_command's built-in chain (no extension registration involved).""" - from test_util import wait_until + from helpers import wait_until server.running = True dest = DummySocket() diff --git a/test/test_forward_msg_attribution.py b/test/integration/test_forward_msg_attribution.py similarity index 99% rename from test/test_forward_msg_attribution.py rename to test/integration/test_forward_msg_attribution.py index e8f3e88..8ea75b9 100644 --- a/test/test_forward_msg_attribution.py +++ b/test/integration/test_forward_msg_attribution.py @@ -26,7 +26,7 @@ import pytest -from test_util import server_ready, wait_until +from helpers import server_ready, wait_until from PyFlow.network_api.connect_tcp import ( TCP_Client_Base, diff --git a/test/test_instance_setup/test_TCP.py b/test/test_instance_setup/test_TCP.py deleted file mode 100644 index c215459..0000000 --- a/test/test_instance_setup/test_TCP.py +++ /dev/null @@ -1,58 +0,0 @@ -import os -import sys -import time -import subprocess - -package_dictionary = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -if package_dictionary not in os.sys.path: - sys.path.insert(0, package_dictionary) - - -class TestConnect: - def __init__(self): - # breakpoint() - create_tcp_client_amount = int(input()) - if sys.platform.startswith("win"): - self.TCP_server_process = subprocess.Popen( - ["python", os.path.join(os.path.dirname(__file__), "test_TCP_server.py")], - creationflags=subprocess.CREATE_NEW_CONSOLE, - ) - # self.TCP_server_process=subprocess.Popen( - # ["python", os.path.join(os.path.dirname(__file__), 'test_TCP_server.py')]) - time.sleep(2) - for i in range(create_tcp_client_amount): - time.sleep(0.5) - subprocess.Popen( - ["python", os.path.join(os.path.dirname(__file__), "test_TCP_client.py")], - creationflags=subprocess.CREATE_NEW_CONSOLE, - ) - # subprocess.Popen( - # ["python", os.path.join(os.path.dirname(__file__), 'test_TCP_client.py')]) - else: - cmd = [ - "gnome-terminal", - "--", - "bash", - "-c", - "python3.14 {}".format( - os.path.join(os.path.dirname(__file__), "test_TCP_server.py") - ), - ] - self.TCP_server_process = subprocess.Popen(cmd) - time.sleep(2) - for i in range(create_tcp_client_amount): - cmd = [ - "gnome-terminal", - "--", - "bash", - "-c", - "python3.14 {}".format( - os.path.join(os.path.dirname(__file__), "test_TCP_client.py") - ), - ] - time.sleep(0.5) - subprocess.Popen(cmd) - - -if __name__ == "__main__": - TestConnect() diff --git a/test/test_instance_setup/test_TCP_client.py b/test/test_instance_setup/test_TCP_client.py deleted file mode 100644 index 611cb83..0000000 --- a/test/test_instance_setup/test_TCP_client.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import sys - -package_dictionary = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -if package_dictionary not in os.sys.path: - sys.path.insert(0, package_dictionary) -from PyFlow.network_api import connect_tcp - - -def test_TCP_client(): - connect_tcp.TCP_Client_Base(host="127.0.0.1") - - -test_TCP_client() diff --git a/test/test_instance_setup/test_TCP_server.py b/test/test_instance_setup/test_TCP_server.py deleted file mode 100644 index 49e1260..0000000 --- a/test/test_instance_setup/test_TCP_server.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import sys - -package_dictionary = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -if package_dictionary not in os.sys.path: - sys.path.insert(0, package_dictionary) -from PyFlow.network_api import connect_tcp - - -def test_TCP_server(): - connect_tcp.TCP_Server_Base() - - -test_TCP_server() diff --git a/test/test_instance_setup/test_extension_TCP.py b/test/test_instance_setup/test_extension_TCP.py deleted file mode 100644 index f6bffbf..0000000 --- a/test/test_instance_setup/test_extension_TCP.py +++ /dev/null @@ -1,61 +0,0 @@ -import os -import sys -import subprocess -import time - -package_dictionary = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -if package_dictionary not in os.sys.path: - sys.path.insert(0, package_dictionary) - - -class TestConnect: - def __init__(self): - # breakpoint() - create_tcp_client_amount = int(input()) - if sys.platform.startswith("win"): - self.TCP_server_process = subprocess.Popen( - ["python", os.path.join(os.path.dirname(__file__), "test_extension_TCP_server.py")], - creationflags=subprocess.CREATE_NEW_CONSOLE, - ) - # self.TCP_server_process=subprocess.Popen( - # ["python", os.path.join(os.path.dirname(__file__), 'test_extension_TCP_server.py')]) - time.sleep(2) - for i in range(create_tcp_client_amount): - time.sleep(0.5) - subprocess.Popen( - [ - "python", - os.path.join(os.path.dirname(__file__), "test_extension_TCP_client.py"), - ], - creationflags=subprocess.CREATE_NEW_CONSOLE, - ) - # subprocess.Popen( - # ["python", os.path.join(os.path.dirname(__file__), 'test_extension_TCP_client.py')]) - else: - cmd = [ - "gnome-terminal", - "--", - "bash", - "-c", - "python3.14 {}".format( - os.path.join(os.path.dirname(__file__), "test_extension_TCP_server.py") - ), - ] - self.TCP_server_process = subprocess.Popen(cmd) - time.sleep(2) - for i in range(create_tcp_client_amount): - cmd = [ - "gnome-terminal", - "--", - "bash", - "-c", - "python3.14 {}".format( - os.path.join(os.path.dirname(__file__), "test_extension_TCP_client.py") - ), - ] - time.sleep(0.5) - subprocess.Popen(cmd) - - -if __name__ == "__main__": - TestConnect() diff --git a/test/test_instance_setup/test_extension_TCP_client.py b/test/test_instance_setup/test_extension_TCP_client.py deleted file mode 100644 index bf81852..0000000 --- a/test/test_instance_setup/test_extension_TCP_client.py +++ /dev/null @@ -1,10 +0,0 @@ -import os -import sys - -package_dictionary = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -if package_dictionary not in os.sys.path: - sys.path.insert(0, package_dictionary) -from PyFlow.network_api.connect_tcp import TCP_Client_Base -from PyFlow.command_control_extension_tcp import client_setup - -client_setup() diff --git a/test/test_instance_setup/test_extension_TCP_server.py b/test/test_instance_setup/test_extension_TCP_server.py deleted file mode 100644 index 65ae400..0000000 --- a/test/test_instance_setup/test_extension_TCP_server.py +++ /dev/null @@ -1,10 +0,0 @@ -import os -import sys - -package_dictionary = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -if package_dictionary not in os.sys.path: - sys.path.insert(0, package_dictionary) -from PyFlow.network_api.connect_tcp import TCP_Server_Base -from PyFlow.command_control_extension_tcp import server_setup - -server_setup() diff --git a/test/test_TCP_client.py b/test/unit/network_api/test_TCP_client.py similarity index 100% rename from test/test_TCP_client.py rename to test/unit/network_api/test_TCP_client.py diff --git a/test/test_TCP_server.py b/test/unit/network_api/test_TCP_server.py similarity index 100% rename from test/test_TCP_server.py rename to test/unit/network_api/test_TCP_server.py diff --git a/test/test_crypto_rsa.py b/test/unit/network_api/test_crypto_rsa.py similarity index 100% rename from test/test_crypto_rsa.py rename to test/unit/network_api/test_crypto_rsa.py diff --git a/test/test_rsa_crypto_errors.py b/test/unit/network_api/test_rsa_crypto_errors.py similarity index 98% rename from test/test_rsa_crypto_errors.py rename to test/unit/network_api/test_rsa_crypto_errors.py index 9dee6da..05f86f2 100644 --- a/test/test_rsa_crypto_errors.py +++ b/test/unit/network_api/test_rsa_crypto_errors.py @@ -4,12 +4,13 @@ import os import sys import ctypes +from pathlib import Path import pytest import PyFlow.network_api.rsa_crypto as rc -PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +PROJECT_ROOT = str(Path(__file__).resolve().parents[3]) try: rc.load_library() diff --git a/test/test_flow_setup.py b/test/unit/test_flow_setup.py similarity index 100% rename from test/test_flow_setup.py rename to test/unit/test_flow_setup.py