Skip to content

Commit

Permalink
fix #284 - use vcr for test caching: only some functions done
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Dec 1, 2018
1 parent 8b4c7cf commit 0067175
Show file tree
Hide file tree
Showing 35 changed files with 2,922 additions and 293 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Imports:
tibble,
isdparser (>= 0.2.0),
geonames,
hoardr
hoardr (>= 0.5.2)
Suggests:
roxygen2 (>= 6.1.1),
testthat,
Expand All @@ -55,7 +55,9 @@ Suggests:
rmarkdown,
purrr,
ggmap,
ropenaq
ropenaq,
vcr
Remotes: ropensci/hoardr
RoxygenNote: 6.1.1
X-schema.org-applicationCategory: Climate
X-schema.org-keywords: earth, science, climate, precipitation, temperature, storm, buoy, NCDC, NOAA, tornadoe, sea ice, ISD
Expand Down
12 changes: 6 additions & 6 deletions R/onload.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ bsw_cache <- NULL
z$cache_path_set("noaa_cmorph")
cmorph_cache <<- z

z <- hoardr::hoard()
z$cache_path_set("noaa_lcd")
lcd_cache <<- z
w <- hoardr::hoard()
w$cache_path_set("noaa_lcd")
lcd_cache <<- w

z <- hoardr::hoard()
z$cache_path_set("noaa_bsw")
bsw_cache <<- z
m <- hoardr::hoard()
m$cache_path_set("noaa_bsw")
bsw_cache <<- m
}
1 change: 1 addition & 0 deletions tests/fixtures/arc2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

36 changes: 36 additions & 0 deletions tests/fixtures/coops_search.yml

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions tests/fixtures/coops_search_fail_no_data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
http_interactions:
- request:
method: get
uri: https://tidesandcurrents.noaa.gov/api/datagetter?begin_date=20140927&end_date=20140928&station=8775244&product=air_temperature&units=metric&time_zone=gmt&application=rnoaa&format=json
body:
encoding: ''
string: ''
headers:
User-Agent: libcurl/7.54.0 r-curl/3.2 crul/0.6.0
Accept-Encoding: gzip, deflate
Accept: application/json, text/xml, application/xml, */*
response:
status:
status_code: '200'
message: OK
explanation: Request fulfilled, document follows
headers:
status: HTTP/1.1 200 OK
date: Sat, 01 Dec 2018 19:40:28 GMT
server: Apache-Coyote/1.1
cache-control: no-cache,no-store,must-revalidate
pragma: no-cache
expires: Thu, 01 Jan 1970 00:00:00 GMT
access-control-allow-headers: X-Requested-With
access-control-allow-origin: '*'
content-type: text/html;charset=ISO-8859-1
vary: User-Agent,Accept-Encoding
content-encoding: gzip
content-length: '115'
strict-transport-security: max-age=31536000; includeSubDomains; preload;
body:
encoding: UTF-8
string: |
{"error": {"message":"No data was found. This product may not be offered at this station at the requested time."}}
recorded_at: 2018-12-01 19:40:22 GMT
recorded_with: vcr/0.2.0, webmockr/0.2.9
1 change: 1 addition & 0 deletions tests/fixtures/coops_search_fail_no_datum.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

72 changes: 72 additions & 0 deletions tests/fixtures/ghcnd_countries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
http_interactions:
- request:
method: get
uri: ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/ghcnd-countries.txt
body:
encoding: ''
string: ''
headers:
User-Agent: libcurl/7.54.0 r-curl/3.2 crul/0.6.0
Accept-Encoding: gzip, deflate
Accept: application/json, text/xml, application/xml, */*
response:
status:
status_code: '226'
message: IM Used
explanation: RFC 3229
headers: []
body:
encoding: UTF-8
string: "AC Antigua and Barbuda \nAE United Arab Emirates \nAF Afghanistan\nAG
Algeria \nAJ Azerbaijan \nAL Albania\nAM Armenia \nAO Angola \nAQ American
Samoa [United States] \nAR Argentina \nAS Australia \nAU Austria \nAY Antarctica
\nBA Bahrain \nBB Barbados \nBC Botswana \nBD Bermuda [United Kingdom] \nBE
Belgium \nBF Bahamas, The \nBG Bangladesh\nBH Belize\nBK Bosnia and Herzegovina
\nBL Bolivia \nBM Burma\nBN Benin \nBO Belarus \nBP Solomon Islands \nBR Brazil\nBU
Bulgaria\nBX Brunei\nBY Burundi\nCA Canada \nCB Cambodia\nCD Chad \nCE Sri
Lanka \nCF Congo (Brazzaville) \nCG Congo (Kinshasa)\nCH China \nCI Chile
\nCJ Cayman Islands [United Kingdom] \nCK Cocos (Keeling) Islands [Australia]
\nCM Cameroon \nCO Colombia \nCQ Northern Mariana Islands [United States]
\nCS Costa Rica \nCT Central African Republic \nCU Cuba \nCV Cape Verde\nCW
Cook Islands [New Zealand]\nCY Cyprus \nDA Denmark \nDO Dominica\nDR Dominican
Republic \nEC Ecuador \nEG Egypt \nEI Ireland \nEK Equatorial Guinea\nEN Estonia
\nER Eritrea \nES El Salvador \nET Ethiopia \nEU Europa Island [France]\nEZ
Czech Republic \nFG French Guiana [France] \nFI Finland \nFJ Fiji\nFK Falkland
Islands (Islas Malvinas) [United Kingdom] \nFM Federated States of Micronesia
\nFP French Polynesia \nFR France \nFS French Southern and Antarctic Lands
[France]\nGA Gambia, The \nGB Gabon \nGG Georgia\nGH Ghana\nGI Gibraltar [United
Kingdom]\nGL Greenland [Denmark] \nGM Germany \nGP Guadeloupe [France] \nGQ
Guam [United States] \nGR Greece \nGT Guatemala \nGV Guinea \nGY Guyana \nHO
Honduras \nHR Croatia\nHU Hungary \nIC Iceland \nID Indonesia \nIN India \nIO
British Indian Ocean Territory [United Kingdom] \nIR Iran \nIS Israel \nIT
Italy \nIV Cote D'Ivoire \nIZ Iraq \nJA Japan \nJM Jamaica \nJN Jan Mayen
[Norway] \nJO Jordan\nJQ Johnston Atoll [United States] \nJU Juan De Nova
Island [France]\nKE Kenya \nKG Kyrgyzstan \nKN Korea, North \nKR Kiribati
\nKS Korea, South \nKT Christmas Island [Australia] \nKU Kuwait \nKZ Kazakhstan
\nLA Laos \nLE Lebanon\nLG Latvia \nLH Lithuania\nLI Liberia \nLO Slovakia
\nLQ Palmyra Atoll [United States] \nLT Lesotho \nLU Luxembourg \nLY Libya
\nMA Madagascar \nMB Martinique [France]\nMC Macau S.A.R\nMD Moldova \nMF
Mayotte [France]\nMG Mongolia \nMI Malawi\nMJ Montenegro \nMK Macedonia \nML
Mali \nMO Morocco \nMP Mauritius \nMQ Midway Islands [United States} \nMR
Mauritania \nMT Malta \nMU Oman \nMV Maldives \nMX Mexico \nMY Malaysia \nMZ
Mozambique \nNC New Caledonia [France] \nNE Niue [New Zealand]\nNF Norfolk
Island [Australia]\nNG Niger \nNH Vanuatu \nNI Nigeria\nNL Netherlands \nNN
Sint Maarten\nNO Norway \nNP Nepal \nNS Suriname\nNU Nicaragua \nNZ New Zealand
\nPA Paraguay \nPC Pitcairn Islands [United Kingdom] \nPE Peru \nPK Pakistan
\nPL Poland \nPM Panama \nPO Portugal \nPP Papua New Guinea \nPS Palau\nPU
Guinea-Bissau\nQA Qatar\nRE Reunion [France]\nRI Serbia\nRM Marshall Islands
\nRO Romania \nRP Philippines \nRQ Puerto Rico [United States] \nRS Russia
\nRW Rwanda\nSA Saudi Arabia \nSB Saint Pierre and Miquelon [France]\nSE Seychelles
\nSF South Africa \nSG Senegal \nSH Saint Helena [United Kingdom] \nSI Slovenia
\nSL Sierra Leone \nSN Singapore\nSP Spain \nST Saint Lucia \nSU Sudan \nSV
Svalbard [Norway] \nSW Sweden \nSX South Georgia and the South Sandwich Islands
[United Kingdom]\nSY Syria \nSZ Switzerland \nTD Trinidad and Tobago \nTE
Tromelin Island [France]\nTH Thailand \nTI Tajikistan \nTL Tokelau [New Zealand]
\nTN Tonga \nTO Togo \nTS Tunisia \nTU Turkey \nTV Tuvalu \nTX Turkmenistan
\nTZ Tanzania \nUC Curacao\nUG Uganda\nUK United Kingdom \nUP Ukraine \nUS
United States \nUV Burkina Faso \nUY Uruguay \nUZ Uzbekistan \nVE Venezuela
\nVM Vietnam \nVQ Virgin Islands [United States] \nWA Namibia \nWF Wallis
and Futuna [France]\nWI Western Sahara \nWQ Wake Island [United States]\nWZ
Swaziland \nZA Zambia \nZI Zimbabwe \n"
recorded_at: 2018-12-01 19:48:03 GMT
recorded_with: vcr/0.2.0, webmockr/0.2.9
36 changes: 36 additions & 0 deletions tests/fixtures/ghcnd_states.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
http_interactions:
- request:
method: get
uri: ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/ghcnd-states.txt
body:
encoding: ''
string: ''
headers:
User-Agent: libcurl/7.54.0 r-curl/3.2 crul/0.6.0
Accept-Encoding: gzip, deflate
Accept: application/json, text/xml, application/xml, */*
response:
status:
status_code: '226'
message: IM Used
explanation: RFC 3229
headers: []
body:
encoding: UTF-8
string: "AB ALBERTA\nAK ALASKA\nAL ALABAMA \nAR
ARKANSAS\nAS AMERICAN SAMOA\nAZ ARIZONA\nBC BRITISH COLUMBIA\nCA CALIFORNIA\nCO
COLORADO\nCT CONNECTICUT\nDC DISTRICT OF COLUMBIA\nDE DELAWARE\nFL FLORIDA\nFM
MICRONESIA\nGA GEORGIA\nGU GUAM\nHI HAWAII\nIA IOWA\nID IDAHO\nIL ILLINOIS\nIN
INDIANA\nKS KANSAS\nKY KENTUCKY\nLA LOUISIANA\nMA MASSACHUSETTS\nMB MANITOBA\nMD
MARYLAND\nME MAINE\nMH MARSHALL ISLANDS\nMI MICHIGAN\nMN MINNESOTA\nMO MISSOURI\nMP
NORTHERN MARIANA ISLANDS\nMS MISSISSIPPI\nMT MONTANA\nNB NEW BRUNSWICK\nNC
NORTH CAROLINA\nND NORTH DAKOTA\nNE NEBRASKA\nNH NEW HAMPSHIRE\nNJ NEW JERSEY\nNL
NEWFOUNDLAND AND LABRADOR\nNM NEW MEXICO\nNS NOVA SCOTIA\nNT NORTHWEST TERRITORIES\nNU
NUNAVUT\nNV NEVADA\nNY NEW YORK\nOH OHIO\nOK OKLAHOMA\nON ONTARIO\nOR OREGON\nPA
PENNSYLVANIA\nPE PRINCE EDWARD ISLAND\nPI PACIFIC ISLANDS\nPR PUERTO RICO\nPW
PALAU\nQC QUEBEC\nRI RHODE ISLAND\nSC SOUTH CAROLINA\nSD SOUTH DAKOTA\nSK
SASKATCHEWAN\nTN TENNESSEE\nTX TEXAS\nUM U.S. MINOR OUTLYING ISLANDS\nUT UTAH\nVA
VIRGINIA\nVI VIRGIN ISLANDS\nVT VERMONT\nWA WASHINGTON\nWI WISCONSIN\nWV WEST
VIRGINIA\nWY WYOMING\nYT YUKON TERRITORY\n"
recorded_at: 2018-12-01 19:48:01 GMT
recorded_with: vcr/0.2.0, webmockr/0.2.9
24 changes: 24 additions & 0 deletions tests/fixtures/ghcnd_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
http_interactions:
- request:
method: get
uri: ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/ghcnd-version.txt
body:
encoding: ''
string: ''
headers:
User-Agent: libcurl/7.54.0 r-curl/3.2 crul/0.6.0
Accept-Encoding: gzip, deflate
Accept: application/json, text/xml, application/xml, */*
response:
status:
status_code: '226'
message: IM Used
explanation: RFC 3229
headers: []
body:
encoding: UTF-8
string: |
The current version of GHCN Daily is 3.25-upd-2018113019 (i.e, an update that started at 2018113019 [yyyymmddhh] UTC; yyyy=year; mm=month; dd=day; hh=hour),
created by appending recently available data updates to the last fully reprocessed version: 3.25-por-2018111819.
recorded_at: 2018-12-01 19:48:05 GMT
recorded_with: vcr/0.2.0, webmockr/0.2.9
Loading

0 comments on commit 0067175

Please sign in to comment.