|
1 | | -from pathlib import Path |
| 1 | +from pathlib import PosixPath |
2 | 2 |
|
3 | 3 | import pytest |
4 | 4 |
|
5 | 5 | import datahugger |
6 | | -from datahugger.utils import _is_url |
7 | 6 |
|
8 | | -TESTS_URLS = [ |
9 | | - # Zenodo |
10 | | - ("10.5281/zenodo.6625880", "README.md"), |
11 | | - # Dataverse |
12 | | - ( |
13 | | - "https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/KBHLOD", |
14 | | - "tutorial1.py", |
15 | | - ), |
16 | | - ("https://doi.org/10.7910/DVN/KBHLOD", "tutorial1.py"), |
17 | | - ("https://hdl.handle.net/10622/NHJZUD", "ERRHS_7_01_data_1795.tab"), |
18 | | - # Dataverse single file |
19 | | - ("10.7910/DVN/HZBYG7/RQ26H2", "Table 2.do"), |
20 | | - # Figshare |
21 | | - ("https://doi.org/10.6084/m9.figshare.8851784.v1", "cross_year_data2.csv"), |
22 | | - ( |
23 | | - "https://figshare.com/articles/dataset/Long-term_behavioral_repeatability_in_wild_adult_and_captive_juvenile_turtles_implications_for_personality_development/8851784", |
24 | | - "cross_year_data2.csv", |
25 | | - ), |
26 | | - ( |
27 | | - "https://doi.org/10.15131/shef.data.22010159.v2", |
28 | | - "ScHARR QUIT evaluation statistical and health economic analysis plan.pdf", |
29 | | - ), |
30 | | - # Djehuty |
31 | | - ("https://doi.org/10.4121/21989216.v1", "README.txt"), |
32 | | - # Dryad |
33 | | - ( |
34 | | - "https://datadryad.org/stash/dataset/doi:10.5061/dryad.31zcrjdm5", |
35 | | - "ReadmeFile.txt", |
36 | | - ), |
37 | | - ("https://doi.org/10.5061/dryad.31zcrjdm5", "ReadmeFile.txt"), |
38 | | - # OSF |
39 | | - ("https://osf.io/ews27/", "Cross-comparison/amarlt1"), |
40 | | - ("https://osf.io/kq573/", "nest_area_data.xlsx"), |
41 | | - ("https://doi.org/10.17605/OSF.IO/KQ573", "nest_area_data.xlsx"), |
42 | | - ("https://doi.org/10.17605/OSF.IO/9X6CA", "jobs.sh"), |
43 | | - # Mendeley |
44 | | - ( |
45 | | - "https://doi.org/10.17632/p6wmtv6t5g.2", |
46 | | - "READMI Stranding Sea Turtle records.pdf", |
47 | | - ), |
48 | | - ("https://doi.org/10.17632/p6wmtv6t5g", "READMI Stranding Sea Turtle records.pdf"), |
49 | | - # Dataone |
50 | | - ("https://doi.org/10.18739/A2KH0DZ42", "2012F_Temperature_Data.csv"), |
51 | | - # DSpace |
52 | | - ("https://uhra.herts.ac.uk/handle/2299/26087", "pdf.pdf"), |
53 | | - ( |
54 | | - "https://repositorioinstitucional.ceu.es/handle/10637/2741", |
55 | | - "Aquaporin_1_JAMartin_et_al_MedSport_2009.pdf", |
56 | | - ), |
57 | | - # Pangaea |
58 | | - ("https://doi.org/10.1594/PANGAEA.954547", "Gubbio_age.tab"), |
59 | | - ("https://doi.pangaea.de/10.1594/PANGAEA.954543", "AA_age.tab"), |
60 | | -] |
61 | 7 |
|
| 8 | +def test_get_repositories(location, files, ignored_files, dh_kwargs, tmpdir): |
| 9 | + datahugger.get(location, tmpdir, **dh_kwargs) |
62 | 10 |
|
63 | | -def test_url_checker(): |
64 | | - assert not _is_url("82949") |
65 | | - assert _is_url("https://doi.org/10.5281/zenodo.6614829") |
| 11 | + if files: |
| 12 | + assert PosixPath(tmpdir, files).exists() |
66 | 13 |
|
| 14 | + if ignored_files: |
| 15 | + assert not PosixPath(tmpdir, ignored_files).exists() |
67 | 16 |
|
68 | | -@pytest.mark.parametrize("url_or_id,output_file", TESTS_URLS) |
69 | | -def test_load_dyno(url_or_id, output_file, tmpdir): |
70 | | - """Load repository with the generic loader.""" |
71 | | - datahugger.get(url_or_id, tmpdir) |
72 | 17 |
|
73 | | - assert Path(tmpdir, output_file).exists() |
| 18 | +@pytest.mark.skip("Not implemented") |
| 19 | +def test_info(location, files, ignored_files, dh_kwargs, tmpdir): |
| 20 | + dh_info = datahugger.info(location) |
74 | 21 |
|
75 | | - |
76 | | -@pytest.mark.parametrize( |
77 | | - "url_or_id", |
78 | | - [ |
79 | | - ("10.5281/zenodo.6614829"), |
80 | | - ("https://zenodo.org/record/6614829"), |
81 | | - ("https://doi.org/10.5281/zenodo.6614829"), |
82 | | - ], |
83 | | -) |
84 | | -def test_load_zenodo_6614829(url_or_id, tmpdir): |
85 | | - datahugger.get(url_or_id, tmpdir, max_file_size=1e6) |
86 | | - |
87 | | - assert Path(tmpdir, "quasiperiod.m").exists() |
88 | | - assert not Path(tmpdir, "quasiperiod.txt.gz").exists() |
89 | | - |
90 | | - |
91 | | -def test_load_github_cbsodata(tmpdir): |
92 | | - datahugger.get("https://github.com/j535d165/cbsodata", tmpdir) |
93 | | - |
94 | | - |
95 | | -def test_info_without_loading(tmpdir): |
96 | | - dh_get = datahugger.get("https://osf.io/wdzh5/", output_folder=".", print_only=True) |
97 | | - |
98 | | - dh_info = datahugger.info("https://osf.io/wdzh5/") |
99 | | - |
100 | | - assert dh_get.dataset.files == dh_info.files |
| 22 | + assert files in dh_info.files |
0 commit comments