Commit e6dce4ad authored by Robert Schütz's avatar Robert Schütz
Browse files

python3Packages.rclone-python: run tests

parent 44c0690e
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -2,10 +2,12 @@
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  pytestCheckHook,
  replaceVars,
  setuptools,
  rich,
  rclone,
  writableTmpDirAsHomeHook,
}:

buildPythonPackage rec {
@@ -32,8 +34,28 @@ buildPythonPackage rec {
    rich
  ];

  # tests require working internet connection
  doCheck = false;
  nativeCheckInputs = [
    pytestCheckHook
    writableTmpDirAsHomeHook
  ];

  preCheck = ''
    # Unlike upstream we don't actually run an S3 server for testing.
    # See https://github.com/Johannes11833/rclone_python/blob/master/launch_test_server.sh
    mkdir -p "$HOME/.config/rclone"
    cat > "$HOME/.config/rclone/rclone.conf" <<EOF
    [test_server_s3]
    type = combine
    upstreams = "testdir=$(mktemp -d)"
    EOF
  '';

  disabledTestPaths = [
    # test requires a remote that supports public links
    "tests/test_link.py"
    # test looks up latest version on rclone.org
    "tests/test_version.py"
  ];

  pythonImportsCheck = [ "rclone_python" ];

+30 −0
Original line number Diff line number Diff line
@@ -97,3 +97,33 @@ index d4a8413..1b29bd8 100644
 
     # add optional arguments and flags to the command
     args_str = args2string(args)
diff --git a/tests/test_copy.py b/tests/test_copy.py
index 4ded5fa..1cae53b 100644
--- a/tests/test_copy.py
+++ b/tests/test_copy.py
@@ -45,11 +45,11 @@ def create_local_file(
 @pytest.mark.parametrize(
     "wrapper_command,rclone_command",
     [
-        (rclone.copy, "rclone copy"),
-        (rclone.copyto, "rclone copyto"),
-        (rclone.sync, "rclone sync"),
-        (rclone.move, "rclone move"),
-        (rclone.moveto, "rclone moveto"),
+        (rclone.copy, "@rclone@ copy"),
+        (rclone.copyto, "@rclone@ copyto"),
+        (rclone.sync, "@rclone@ sync"),
+        (rclone.move, "@rclone@ move"),
+        (rclone.moveto, "@rclone@ moveto"),
     ],
 )
 def test_rclone_command_called(wrapper_command: Callable, rclone_command: str):
@@ -62,7 +62,7 @@ def test_rclone_command_called(wrapper_command: Callable, rclone_command: str):
         rclone.utils.subprocess,
         "Popen",
         return_value=subprocess.Popen(
-            "rclone help", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
+            "@rclone@ help", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
         ),
     ) as mock:
         wrapper_command("nothing/not_a.file", "fake_remote:unicorn/folder")