about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBruno BELANYI <bruno@belanyi.fr>2023-12-24 22:23:15 +0100
committerBruno BELANYI <bruno@belanyi.fr>2024-01-23 15:07:40 +0000
commit60518d6a5245bbd48b0d043549d6e22209474873 (patch)
tree3bfadd8eaf751038ae96e7214f7054dbb95720dd
parent70d0a6e54786994fb41f66796e20aff224028faa (diff)
downloadnixlib-60518d6a5245bbd48b0d043549d6e22209474873.tar
nixlib-60518d6a5245bbd48b0d043549d6e22209474873.tar.gz
nixlib-60518d6a5245bbd48b0d043549d6e22209474873.tar.bz2
nixlib-60518d6a5245bbd48b0d043549d6e22209474873.tar.lz
nixlib-60518d6a5245bbd48b0d043549d6e22209474873.tar.xz
nixlib-60518d6a5245bbd48b0d043549d6e22209474873.tar.zst
nixlib-60518d6a5245bbd48b0d043549d6e22209474873.zip
nixos/pyload: init test
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/pyload.nix33
-rw-r--r--pkgs/applications/networking/pyload-ng/default.nix24
3 files changed, 49 insertions, 9 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 25ee587e8f7a..fc1f047d42cf 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -387,6 +387,7 @@ in {
   installed-tests = pkgs.recurseIntoAttrs (handleTest ./installed-tests {});
   invidious = handleTest ./invidious.nix {};
   livebook-service = handleTest ./livebook-service.nix {};
+  pyload = handleTest ./pyload.nix {};
   oci-containers = handleTestOn ["aarch64-linux" "x86_64-linux"] ./oci-containers.nix {};
   odoo = handleTest ./odoo.nix {};
   odoo15 = handleTest ./odoo.nix { package = pkgs.odoo15; };
diff --git a/nixos/tests/pyload.nix b/nixos/tests/pyload.nix
new file mode 100644
index 000000000000..f913e822b2ff
--- /dev/null
+++ b/nixos/tests/pyload.nix
@@ -0,0 +1,33 @@
+import ./make-test-python.nix ({ lib, ... }: {
+  name = "pyload";
+  meta.maintainers = with lib.maintainers; [ ambroisie ];
+
+  nodes = {
+    machine = { ... }: {
+      services.pyload = {
+        enable = true;
+
+        listenAddress = "0.0.0.0";
+        port = 9876;
+      };
+
+      networking.firewall.allowedTCPPorts = [ 9876 ];
+    };
+
+    client = { };
+  };
+
+  testScript = ''
+    start_all()
+
+    machine.wait_for_unit("pyload.service")
+
+    with subtest("Web interface accessible locally"):
+        machine.wait_until_succeeds("curl -fs localhost:9876")
+
+    client.wait_for_unit("network.target")
+
+    with subtest("Web interface accessible from a different machine"):
+        client.wait_until_succeeds("curl -fs machine:9876")
+  '';
+})
diff --git a/pkgs/applications/networking/pyload-ng/default.nix b/pkgs/applications/networking/pyload-ng/default.nix
index eb0b6af94efe..1f638d43daef 100644
--- a/pkgs/applications/networking/pyload-ng/default.nix
+++ b/pkgs/applications/networking/pyload-ng/default.nix
@@ -1,4 +1,4 @@
-{ lib, fetchPypi, python3 }:
+{ lib, fetchPypi, nixosTests, python3 }:
 
 python3.pkgs.buildPythonApplication rec {
   version = "0.5.0b3.dev75";
@@ -43,14 +43,20 @@ python3.pkgs.buildPythonApplication rec {
     setuptools
   ];
 
-  passthru.optional-dependencies = {
-    plugins = with python3.pkgs; [
-      beautifulsoup4 # for some plugins
-      colorlog # colorful console logging
-      pillow # for some CAPTCHA plugin
-      send2trash # send some files to trash instead of deleting them
-      slixmpp # XMPP plugin
-    ];
+  passthru = {
+    optional-dependencies = {
+      plugins = with python3.pkgs; [
+        beautifulsoup4 # for some plugins
+        colorlog # colorful console logging
+        pillow # for some CAPTCHA plugin
+        send2trash # send some files to trash instead of deleting them
+        slixmpp # XMPP plugin
+      ];
+    };
+
+    tests = {
+      inherit (nixosTests) pyload;
+    };
   };
 
   meta = with lib; {