add unit tests for binder dir
MODIFY
repo2docker/__main__.py
repo2docker/__main__.py
@@ -7,6 +7,7 @@ from .app import Repo2Docker
from . import __version__
from .utils import validate_and_generate_port_mapping, is_valid_docker_image_name
+
def validate_image_name(image_name):
"""
Validate image_name read by argparse

ADD
tests/unit/test_binder_dir.py
+import os
+
+import pytest
+
+from repo2docker import buildpacks
+
+
+@pytest.mark.parametrize("binder_dir", ['.binder', 'binder'])
+def test_binder_dir_property(tmpdir, binder_dir):
+ tmpdir.chdir()
+ os.mkdir(binder_dir)
+
+ bp = buildpacks.BuildPack()
+ assert binder_dir in bp.binder_dir
+ assert bp.binder_path('foo.yaml') == os.path.join(binder_dir, 'foo.yaml')
+
+
+def test_root_binder_dir(tmpdir):
+ tmpdir.chdir()
+ bp = buildpacks.BuildPack()
+ assert bp.binder_dir == ''
+
+
+def test_exclusive_binder_dir(tmpdir):
+ tmpdir.chdir()
+ os.mkdir('./binder')
+ os.mkdir('./.binder')
+
+ bp = buildpacks.BuildPack()
+ with pytest.raises(RuntimeError):
+ _ = bp.binder_dir

add unit tests for binder dir