2019-04-30 15:35:58 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from repo2docker import buildpacks
|
|
|
|
|
|
|
|
|
2020-07-08 15:58:30 +00:00
|
|
|
@pytest.mark.parametrize("binder_dir", ["binder", ".binder", ""])
|
|
|
|
def test_binder_dir(tmpdir, binder_dir):
|
2019-04-30 15:35:58 +00:00
|
|
|
tmpdir.chdir()
|
2020-07-08 15:58:30 +00:00
|
|
|
if binder_dir:
|
|
|
|
os.mkdir(binder_dir)
|
2019-04-30 15:35:58 +00:00
|
|
|
|
|
|
|
bp = buildpacks.BuildPack()
|
2020-07-08 15:58:30 +00:00
|
|
|
assert binder_dir == bp.binder_dir
|
2019-05-31 09:10:17 +00:00
|
|
|
assert bp.binder_path("foo.yaml") == os.path.join(binder_dir, "foo.yaml")
|
2019-04-30 15:35:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_exclusive_binder_dir(tmpdir):
|
|
|
|
tmpdir.chdir()
|
2019-05-31 09:10:17 +00:00
|
|
|
os.mkdir("./binder")
|
|
|
|
os.mkdir("./.binder")
|
2019-04-30 15:35:58 +00:00
|
|
|
|
|
|
|
bp = buildpacks.BuildPack()
|
|
|
|
with pytest.raises(RuntimeError):
|
|
|
|
_ = bp.binder_dir
|