-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Arkoniak/dev
Custom parsers and keyword arguments
- Loading branch information
Showing
6 changed files
with
206 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,16 @@ | ||
module TestUrlDownload | ||
using Test | ||
using UrlDownload | ||
|
||
@testset "Standard CSVs" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/ext.csv" | ||
res = urldownload(url) | ||
for file in sort([file for file in readdir(@__DIR__) if | ||
match(r"^test.*_.*\.jl$", file) !== nothing]) | ||
m = match(r"^test[_0-9]*(.*).jl$", file) | ||
|
||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/ext.tsv" | ||
res = urldownload(url) | ||
@testset "$(m[1])" begin | ||
# Here you can optionally exclude some test files | ||
# VERSION < v"1.1" && file == "test_xxx.jl" && continue | ||
|
||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/noextcsv" | ||
res = urldownload(url, format = :CSV) | ||
|
||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/noexttsv" | ||
res = urldownload(url, format = :TSV) | ||
end | ||
|
||
@testset "Force format CSVs" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/semicolon.csv" | ||
res = urldownload(url) | ||
|
||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/semicolonnoextcsv" | ||
res = urldownload(url, format = :CSV) | ||
end | ||
|
||
@testset "Pics" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/test.jpg" | ||
res = urldownload(url) | ||
|
||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/test.png" | ||
res = urldownload(url) | ||
end | ||
|
||
@testset "Feather" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/test.feather" | ||
res = urldownload(url) | ||
include(file) | ||
end | ||
end | ||
|
||
@testset "Json" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/test.json" | ||
res = urldownload(url) | ||
end | ||
|
||
@testset "Progress meter" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/ext.csv" | ||
res = urldownload(url, true) | ||
end | ||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module TestBasic | ||
|
||
using Test | ||
using UrlDownload | ||
|
||
@testset "Standard CSVs" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/ext.csv" | ||
res = urldownload(url) | ||
|
||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/ext.tsv" | ||
res = urldownload(url) | ||
|
||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/noextcsv" | ||
res = urldownload(url, format = :CSV) | ||
|
||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/noexttsv" | ||
res = urldownload(url, format = :TSV) | ||
end | ||
|
||
@testset "Force format CSVs" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/semicolon.csv" | ||
res = urldownload(url) | ||
|
||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/semicolonnoextcsv" | ||
res = urldownload(url, format = :CSV) | ||
end | ||
|
||
@testset "Pics" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/test.jpg" | ||
res = urldownload(url) | ||
|
||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/test.png" | ||
res = urldownload(url) | ||
end | ||
|
||
@testset "Feather" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/test.feather" | ||
res = urldownload(url) | ||
end | ||
|
||
@testset "Json" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/test.json" | ||
res = urldownload(url) | ||
end | ||
|
||
@testset "Progress meter" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/ext.csv" | ||
res = urldownload(url, true) | ||
end | ||
|
||
@testset "Keyword arguments" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/semicolon.csv" | ||
res = urldownload(url, delim = ';') | ||
end | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module TestWrapper | ||
|
||
using Test | ||
using UrlDownload | ||
using DataFrames | ||
using CSV | ||
|
||
wrapper(x; kw...) = DataFrame(CSV.File(IOBuffer(x); kw...)) | ||
|
||
@testset "wrappers" begin | ||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/ext.csv" | ||
res = urldownload(url, parser = x -> DataFrame(CSV.File(IOBuffer(x)))) | ||
|
||
url = "https://raw.githubusercontent.com/Arkoniak/UrlDownload.jl/master/data/semicolon.csv" | ||
res = urldownload(url, parser = wrapper, delim = ';') | ||
end | ||
|
||
end # module |