Skip to content

Commit 2fde822

Browse files
committed
Check SHA256 hash of the downloaded files
1 parent cd1934d commit 2fde822

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
*.jl.mem
44
.DS_Store
55
/Manifest.toml
6-
/dev/
6+
/test/data/

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ julia = "^1.0.0"
1515
[extras]
1616
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
1717
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
18+
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
1819
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1920

2021
[targets]
21-
test = ["Conda", "PyCall", "Test"]
22+
test = ["Conda", "PyCall", "SHA", "Test"]

test/core.jl

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
1-
@testset "reproject-core" begin
2-
if !isfile("data/gc_2mass_k.fits")
3-
mkpath("data")
4-
download("https://astropy.stsci.edu/data/galactic_center/gc_2mass_k.fits", "data/gc_2mass_k.fits")
5-
end
6-
if !isfile("data/gc_msx_e.fits")
7-
mkpath("data")
8-
download("https://astropy.stsci.edu/data/galactic_center/gc_msx_e.fits", "data/gc_msx_e.fits")
1+
function download_dep(orig, dest, hash)
2+
dest_file = joinpath("data", dest)
3+
if isfile(dest_file)
4+
dest_hash = open(dest_file, "r") do f
5+
bytes2hex(sha256(f))
6+
end
7+
if dest_hash == hash
8+
return nothing
9+
end
910
end
11+
mkpath("data")
12+
download(orig, dest_file)
13+
return nothing
14+
end
15+
16+
@testset "reproject-core" begin
17+
download_dep("https://astropy.stsci.edu/data/galactic_center/gc_2mass_k.fits", "gc_2mass_k.fits",
18+
"763ef344df3ac8fa80ff46f00ca1ec59946ca3f99502562d6fcfb73320b1cec3")
19+
download_dep("https://astropy.stsci.edu/data/galactic_center/gc_msx_e.fits", "gc_msx_e.fits",
20+
"3687fb3763911825f981e74b6a9b82c0e618f7e592b1e0cb17e2c63164e28cd6")
1021

11-
imgin = FITS("data/gc_msx_e.fits") # project this
12-
imgout = FITS("data/gc_2mass_k.fits") # into this coordinate
22+
imgin = FITS(joinpath("data", "gc_msx_e.fits")) # project this
23+
imgout = FITS(joinpath("data", "gc_2mass_k.fits")) # into this coordinate
1324

14-
hdu1 = astropy.io.fits.open("data/gc_2mass_k.fits")[1]
15-
hdu2 = astropy.io.fits.open("data/gc_msx_e.fits")[1]
25+
hdu1 = astropy.io.fits.open(joinpath("data", "gc_2mass_k.fits"))[1]
26+
hdu2 = astropy.io.fits.open(joinpath("data", "gc_msx_e.fits"))[1]
1627

1728
function check_diff(arr1, arr2)
1829
diff = 1e-3

test/runtests.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ using Reproject
22
using Test
33
using Conda, PyCall
44
using FITSIO, WCS
5+
using SHA: sha256
56

67
ENV["PYTHON"]=""
78
Conda.add_channel("astropy")
89
Conda.add("reproject")
910
rp = pyimport("reproject")
1011
astropy = pyimport("astropy")
1112

12-
@testset "Reproject.jl" begin
13-
include("parsers.jl")
14-
include("utils.jl")
15-
include("core.jl")
16-
end
13+
include("parsers.jl")
14+
include("utils.jl")
15+
include("core.jl")

0 commit comments

Comments
 (0)