File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010default_url = "https://raw.githubusercontent.com/ddmms/data-tutorials/main/data/"
1111def download_file (url : str , filename :str , dest : Path ) -> None :
1212 save_file = dest / filename
13- path , headers = urlretrieve (url , dest )
13+ print (f"try to download { filename } from { url } and save it in { save_file } " )
14+ path , headers = urlretrieve (url + filename , save_file )
1415 if path .exists ():
1516 print (f"saved in { save_file } " )
1617 else :
Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ build-backend = "setuptools.build_meta"
66[project ]
77name = " data-tutorials"
88dynamic = [" version" ]
9-
9+ dependencies = [
10+ " pytest" ,
11+ ]
1012requires-python = " >=3.9"
1113authors = [
1214 {name = " Alin M Elena" , email = " alin@elena.re" }
@@ -35,3 +37,8 @@ packages = ["data_tutorials"]
3537
3638[tool .setuptools_scm ]
3739
40+
41+ [tool .pytest .ini_options ]
42+ pythonpath = [
43+ " ."
44+ ]
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ # Author; alin m elena, alin@elena.re
3+ # Contribs;
4+ # Date: 26-07-2024
5+ # ©alin m elena, GPL v3 https://www.gnu.org/licenses/gpl-3.0.en.html
6+ import pytest
7+ from data_tutorials .data import get_data
8+ import hashlib
9+ from pathlib import Path
10+
11+ def test_download_file ():
12+ get_data (filename = "LiFePO4_supercell.cif" ,folder = "data-test" )
13+ with open (Path ("data-test" )/ "LiFePO4_supercell.cif" , "rb" ) as f :
14+ h = hashlib .file_digest (f , "sha256" )
15+ assert h .hexdigest () == "ea9a538dde5bb84b92e9478dbcc078bb560b28a4f5e4b0469d416bff36be272e"
You can’t perform that action at this time.
0 commit comments