-
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.
- Loading branch information
Showing
8 changed files
with
45 additions
and
76 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 was deleted.
Oops, something went wrong.
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,51 +1,34 @@ | ||
const DATA_FILENAME = "data.csv" | ||
const DOTENV = "integration/.testenv" | ||
const URL = "$(ModelSelectionGUI.SERVER_URL):$(ModelSelectionGUI.SERVER_PORT)/upload-file" | ||
|
||
const FILENAME = String(ModelSelectionGUI.FILENAME) | ||
const FILEHASH = String(ModelSelectionGUI.FILEHASH) | ||
const DATANAMES = String(ModelSelectionGUI.DATANAMES) | ||
const NOBS = String(ModelSelectionGUI.NOBS) | ||
|
||
@testset "Files" begin | ||
@testset "Upload file successfuly" begin | ||
using HTTP, JSON, CSV, DataFrames | ||
stop() | ||
@testset "Upload file" begin | ||
using HTTP, JSON | ||
URL = "/upload-file" | ||
url = "$(ModelSelectionGUI.SERVER_URL):$(ModelSelectionGUI.SERVER_PORT)$(URL)" | ||
reset_envvars() | ||
start(dotenv = DOTENV) | ||
|
||
file = open(DATA_FILENAME, "r") | ||
request_body = HTTP.Form(Dict(:data => HTTP.Multipart(DATA_FILENAME, file, ModelSelectionGUI.CSV_MIME))) | ||
response = HTTP.post(URL, [], request_body) | ||
body = JSON.parse(String(response.body)) | ||
body = HTTP.Form(Dict(:data => HTTP.Multipart(DATA_FILENAME, file, "text/csv"))) | ||
response = HTTP.post(url, [], body) | ||
msg = String(response.body) | ||
body = JSON.parse(msg) | ||
|
||
data = CSV.read(DATA_FILENAME, DataFrame) | ||
FILENAME = String(ModelSelectionGUI.FILENAME) | ||
FILEHASH = String(ModelSelectionGUI.FILEHASH) | ||
DATANAMES = String(ModelSelectionGUI.DATANAMES) | ||
NOBS = String(ModelSelectionGUI.NOBS) | ||
|
||
@test response.status == ModelSelectionGUI.HTTP_200_OK | ||
@test response.status == 200 | ||
@test haskey(body, FILENAME) | ||
@test body[FILENAME] isa String | ||
@test body[FILENAME] == DATA_FILENAME | ||
@test haskey(body, FILEHASH) | ||
@test body[FILEHASH] isa String | ||
@test haskey(body, DATANAMES) | ||
@test body[DATANAMES] isa Vector | ||
for i in 1:lastindex(names(data)) | ||
@test names(data)[i] == body[DATANAMES][i] | ||
end | ||
@test haskey(body, NOBS) | ||
@test body[NOBS] isa Int64 | ||
@test body[NOBS] == nrow(data) | ||
stop() | ||
end | ||
@testset "Upload file fail: invalid mime" begin | ||
using HTTP, JSON, CSV, DataFrames | ||
stop() | ||
reset_envvars() | ||
start(dotenv = DOTENV) | ||
|
||
file = open(DATA_FILENAME, "r") | ||
request_body = HTTP.Form(Dict(:data => HTTP.Multipart(DATA_FILENAME, file, ModelSelectionGUI.PLAIN_MIME))) | ||
@test HTTP.post(URL, [], request_body).status == ModelSelectionGUI.HTTP_400_BAD_REQUEST | ||
|
||
stop() | ||
end | ||
end |
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