Comments (7)
Eventually for CRAN we will likely need a skip_if_no_auth() function. See riingo helper R file. Must be named helper_*.R for testthat. https://github.com/business-science/riingo/tree/master/tests/testthat
Also might get CRAN push back on donttest{} wrapped code, but I got around it by explaining my reasoning that auth is needed for testing and that I test extensively on Travis for riingo
from fredr.
See the reply from hrbrmstr
here https://stackoverflow.com/questions/47333912/r-package-vignette-include-api-key it covers all the bases of what you should do for API testing.
rtweet
generally follows that advice and sets eval = FALSE
for the chunks in the vignette. Its annoying but its the best you can do i think. I wouldnt try and cache / save data and try and load it in (to mock the API calls) unless it was really small files
http://rtweet.info/articles/intro.html
https://raw.githubusercontent.com/mkearney/rtweet/master/vignettes/intro.Rmd
from fredr.
It kind of depends on how good the API errors are. Normally I do some kind of validity checks on the class of the object, and maybe some other lower level feature. Like limit
should be a non-negative integer, which we can check, but we would let the API check to see if it goes >1000 or >100000 since it changes depending on the endpoint. Other things we can do are ensure that limit
is an integer
(100L
) even if the user passes a numeric
(100
), because it doesn't work with numeric
s. We can perform that autoconversion for them.
Another thing I was planning on doing is making observation_date
(and others like it) only accept Date
objects rather than strings. That way, the format is always correct which we can then use format(x, format = "%Y-%m%-%d")
on to get it in the right format for the API. It also allows us to have unit tests on the observation_date
parameter by checking for a Date
class.
Generally, I was planning on having a capture_args(...)
function that will accept all parameters and perform checks and modifications on them, and will return a param list that can be passed on to use in the API call. I will explain more in the PR tonight
from fredr.
We should also think about cases where 0 row tibbles are returned, because I think i ran into an issues with fredr_series
where that failed with a strange (at least to a user) error.
from fredr.
I see. Any idea on how to deal with vignettes when the API key isn't present?
from fredr.
Thanks for the tip! I'll follow that
from fredr.
Tests were overhauled to adopt this framework in f20f510. We can extend and modify testing as needed as development continues. Some remarks:
- The use of helper functions defined in
R/validation.R
can be used to extend function checking fredr()
endpoint validation (a6d82f8)skip_if_no_key()
defined and used in tests requiring authentication (#29 )- Vignette chunks are cached and not evaluated when the API key is not present (72e5ddd)
from fredr.
Related Issues (20)
- Unable to Install (Broken Dependency?) HOT 2
- Support for FRED Maps HOT 3
- Option to select Seasonally Adjusted Observation HOT 1
- upper bound too low for limit in fredr_category_series() HOT 3
- Pagination HOT 1
- Encoding error with fredr_series_observations HOT 11
- Better test environment for API requests HOT 3
- CRAN issues HOT 25
- Removed from CRAN? HOT 2
- Fredr can't return a legit series_id HOT 3
- Getting fredr back on CRAN HOT 24
- Release fredr 2.0.0
- way to traverse category trees? HOT 4
- This likely isn't an issue with your code, but something to be wary of HOT 3
- Trouble downloading multiple FRED series HOT 5
- fredr() and parameter vintage_dates HOT 5
- M2 not FedFunds
- Release fredr 2.1.0 HOT 1
- fredr appears to be completely broken on my R setup HOT 6
- Capture multiple series simultaneously? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fredr.