Repository: datalad/datalad-installer (language: python)

Issue:
Add a test which would cause testing of brew install
according to coverage report (for me it is all red ATM) of #51 , we have no unittest which would test brew installation.

If brew is a default for OSX (if brew is available), may be it could be a nice generic `datalad_installer.py --sudo=ok git-annex`? if not, could be crafted to force `brew`.

may be to be done before the fix for #52 is merged to see if may be we replicate the need. 


Discussion / hints:

Fix patch:
diff --git a/tox.ini b/tox.ini
index 7543c11..9b1d08d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -5,6 +5,8 @@ isolated_build = True
 minversion = 3.3.0
 
 [testenv]
+# HOME needs to be set in order for brew to work:
+passenv = HOME
 deps =
     flake8~=3.7
     flake8-bugbear


Test patch:
diff --git a/test/test_install.py b/test/test_install.py
index 848fc67..8deb98f 100644
--- a/test/test_install.py
+++ b/test/test_install.py
@@ -2,11 +2,12 @@
 import logging
 from pathlib import Path
 import shlex
+import shutil
 import subprocess
 import tempfile
 import pytest
 import datalad_installer
-from datalad_installer import ON_LINUX, ON_WINDOWS, main
+from datalad_installer import ON_LINUX, ON_MACOS, ON_WINDOWS, main
 
 
 def bin_path(binname):
@@ -268,3 +269,13 @@ def test_install_neurodebian_sudo_ok(mocker):
         check=True,
     )
     assert r.stdout == "ii "
+
+
+@pytest.mark.ci_only
+@pytest.mark.skipif(not ON_MACOS, reason="requires macOS")
+def test_install_git_annex_brew(mocker):
+    spy = mocker.spy(datalad_installer, "runcmd")
+    r = main(["datalad_installer.py", "git-annex", "-m", "brew"])
+    assert r == 0
+    assert spy.call_args_list[-1] == mocker.call("brew", "install", "git-annex")
+    assert shutil.which("git-annex") is not None