kopia lustrzana https://github.com/jupyterhub/repo2docker
Add tests for local content provider
rodzic
c7dc5e1841
commit
71903721d9
|
@ -1,9 +1,8 @@
|
|||
from contextlib import contextmanager
|
||||
import shutil
|
||||
import os
|
||||
import subprocess
|
||||
from tempfile import TemporaryDirectory
|
||||
from repo2docker.contentproviders.git import Git
|
||||
from repo2docker.contentproviders import Git
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
import os
|
||||
from tempfile import TemporaryDirectory, NamedTemporaryFile
|
||||
|
||||
from repo2docker.contentproviders import Local
|
||||
|
||||
|
||||
def test_detect_local_dir():
|
||||
with TemporaryDirectory() as d:
|
||||
local = Local()
|
||||
spec = local.detect(d)
|
||||
|
||||
# should accept a local directory
|
||||
assert spec is not None, spec
|
||||
assert 'path' in spec, spec
|
||||
assert spec['path'] == d
|
||||
|
||||
|
||||
def test_not_detect_local_file():
|
||||
with NamedTemporaryFile() as f:
|
||||
local = Local()
|
||||
spec = local.detect(f.name)
|
||||
|
||||
# should NOT accept a local file
|
||||
assert spec is None, spec
|
||||
|
||||
|
||||
def test_content_available():
|
||||
# create a directory with files, check they are available in the output
|
||||
# directory
|
||||
with TemporaryDirectory() as d:
|
||||
with open(os.path.join(d, 'test'), 'w') as f:
|
||||
f.write("Hello")
|
||||
|
||||
spec = {'path': d}
|
||||
for _ in Local().fetch(spec, d):
|
||||
pass
|
||||
assert os.path.exists(os.path.join(d, 'test'))
|
Ładowanie…
Reference in New Issue