Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_CldfDownload(env, tmppath, mocker, capsys):
from clld.web.adapters.cldf import CldfDownload
mocker.patch('clld.web.adapters.cldf.transaction')
tmp = tmppath / 'dl.zip'
dl = CldfDownload(Dataset, 'clld')
dl.create(env['request'], outfile=tmp, verbose=True)
out, err = capsys.readouterr()
assert 'Value' in out
outdir = tmppath / 'cldf'
with ZipFile(tmp.as_posix()) as zip:
assert 'Wordlist-metadata.json' in zip.namelist()
zip.extractall(str(outdir))
ds = CldfDataset.from_metadata(outdir.joinpath('Wordlist-metadata.json'))
assert ds.module == 'Wordlist'
values = list(ds[ds.primary_table])
assert len(values) == 3
for v in values:
list(ds.sources.expand_refs(v['Source']))