Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json loading tests #425

Closed
wants to merge 6 commits into from
Closed

Conversation

RichardMN
Copy link
Collaborator

This is currently a WIP to address #420.

@RichardMN RichardMN mentioned this pull request Sep 28, 2021
@RichardMN RichardMN marked this pull request as ready for review September 28, 2021 16:08
DataClass_obj$download_JSON()
walk(DataClass_obj$data$raw, function(data) {
testthat::expect_s3_class(data, "data.frame")
testthat::expect_true(nrow(data) > 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these tests (which are copied straight over from the CSV code) sort of implicitly assume that we are getting table-like inputs from JSON but even with the Vietnam data the clean method is having to do more “heavy lifting”, and that’s just because we’re getting three parallel lists of tables (roughly) with a list to tie them together. Conceivably we could have other JSON input which was even further from our rectangular array assumptions but still valid JSON, useful data, and convertible (by cleaning) into something the rest of our class can work with.

I don’t necessarily think this needs to be changed now but I could imagine a case where we have another input which generates valid raw data which fails this test - and I’ve already made the argument about why cleaning should be done in the clean methods so I’m inclined to keep the download functions from starting to squeeze data into our rectangular table straitjacket.

Copy link
Contributor

@seabbs seabbs Sep 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes very much agree. Hmm that does leave us in a bit of a poser then regarding what to test. I suppose that lack of error and the existence of a JSON object as a minimum?

@RichardMN RichardMN linked an issue Sep 28, 2021 that may be closed by this pull request
})
}
)
DataClass_obj$data$raw <- map(vn$data$raw,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will presumably fail if the input isn't a list of dataframes?

@seabbs
Copy link
Contributor

seabbs commented Sep 29, 2021

I think as written download_JSON will be called automatically from test_download which itself gets called automatically when DataClass$test() is called. That means I think that it will run the csv tests and hence maybe fail if the JSON isn't a table?

Not entirely sure what to do about this if we go with supporting non-datra frames as the output from download. I guess having a switch to only run tests if the output is a not JSON?

@RichardMN
Copy link
Collaborator Author

I've just stepped through the test_download (by running test(download = TRUE)) and it is running the same code as for a CSV. It doesn't fail but I don't see how to get it to run through JSON-specific tests either.

@RichardMN RichardMN linked an issue Oct 4, 2021 that may be closed by this pull request
commit 04009e7
Merge: d1630f5 68200f9
Author: Sam Abbott <[email protected]>
Date:   Wed Dec 1 14:27:05 2021 +0000

    Merge pull request epiforecasts#443 from epiforecasts/feature-boostrap-5-in-docs

    Switch to bootstrap 5 for pkgdown

commit 68200f9
Author: Sam Abbott <[email protected]>
Date:   Wed Dec 1 13:52:07 2021 +0000

    switch to bootstrap 5 for pkgdown

commit d1630f5
Merge: 71d7b1f ddbdb8e
Author: Sam Abbott <[email protected]>
Date:   Wed Dec 1 13:48:12 2021 +0000

    Merge pull request epiforecasts#442 from epiforecasts/fix-logo

    Fix giant logo by specifying width instead of height

commit ddbdb8e
Merge: a19643f 71d7b1f
Author: Sam Abbott <[email protected]>
Date:   Wed Dec 1 13:47:52 2021 +0000

    Merge branch 'master' into fix-logo

commit a19643f
Author: Hugo Gruson <[email protected]>
Date:   Wed Dec 1 14:30:11 2021 +0100

    Fix giant logo by specifying width instead of height
    fix epiforecasts#440

commit 71d7b1f
Merge: 2e5cabc fb10488
Author: Sam Abbott <[email protected]>
Date:   Wed Dec 1 10:21:14 2021 +0000

    Merge pull request epiforecasts#438 from epiforecasts/rm-joss-action

    Remove action re-building JOSS paper

commit fb10488
Author: Hugo Gruson <[email protected]>
Date:   Tue Nov 30 19:09:00 2021 +0100

    Remove action re-building JOSS paper

commit 2e5cabc
Author: Sam Abbott <[email protected]>
Date:   Mon Nov 29 13:43:29 2021 +0000

    Update NEWS.md

commit d1350d9
Merge: 8c77b82 782256c
Author: Sam Abbott <[email protected]>
Date:   Mon Nov 29 13:41:00 2021 +0000

    Merge pull request epiforecasts#436 from epiforecasts/fix-germany

    fix Germany case/death data

commit 782256c
Author: Sebastian Funk <[email protected]>
Date:   Mon Nov 29 07:40:01 2021 +0000

    add missing sum

commit 4c7cb8c
Author: Sebastian Funk <[email protected]>
Date:   Mon Nov 29 07:19:09 2021 +0000

    fix Germany case/death data

commit 8c77b82
Author: Sam Abbott <[email protected]>
Date:   Tue Oct 12 10:20:55 2021 +0100

    Check package once a week vs daily

commit b5b9cbf
Merge: c782b57 91d0f0c
Author: Sam Abbott <[email protected]>
Date:   Thu Sep 30 13:01:56 2021 +0100

    Merge pull request epiforecasts#428 from RichardMN/update-Vietnam-url-and-docs

    Update vietnam url and docs

commit 91d0f0c
Author: Richard Martin-Nielsen <[email protected]>
Date:   Thu Sep 30 09:12:37 2021 +0300

    Rebuilt all country data table and Vietnam documentation

commit 1d6c024
Author: Tri Luu <[email protected]>
Date:   Thu Sep 30 09:38:37 2021 +0700

    Update stable API URL of Vietnam
@github-actions
Copy link

github-actions bot commented Feb 1, 2022

This PR has been flagged as stale due to lack of activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests for download_JSON and JSON_reader 0.9.3 -> CRAN
3 participants