Skip to content

Commit

Permalink
trying vcr with some tests that include taxize pkg, #32
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Apr 5, 2018
1 parent be6e890 commit 9fa5420
Show file tree
Hide file tree
Showing 8 changed files with 552 additions and 49 deletions.
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description: Tools for working with 'taxonomic' databases, including
utilities for downloading databases, loading them into various
'SQL' databases, cleaning up files, and providing a 'SQL' connection
that can be used to do 'SQL' queries directly or used in 'dplyr'.
Version: 0.1.7.9600
Version: 0.1.7.9610
Authors@R: c(
person("Scott", "Chamberlain", email = "[email protected]", role = c("aut", "cre")),
person("Zebulun", "Arendsee", role = "aut")
Expand All @@ -31,6 +31,9 @@ Imports:
hoardr (>= 0.1.0)
Suggests:
roxygen2 (>= 6.0.1),
taxize,
testthat,
taxize
webmockr (>= 0.2.1.9222),
vcr (>= 0.0.7.9316)
Remotes: ropensci/vcr, ropensci/webmockr
RoxygenNote: 6.0.1
204 changes: 204 additions & 0 deletions tests/fixtures/vcr_cassettes/children_unambiguous.yml

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions tests/fixtures/vcr_cassettes/classification_invalid_ids1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
http_interactions:
- request:
method: get
uri: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=taxonomy&ID=9999999999&api_key=eea6131e94f20ca3f84bb345e8a4f9f4c108
body:
encoding: ''
string: ''
headers:
User-Agent: libcurl/7.54.0 r-curl/3.2 crul/0.5.2
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: Thu, 05 Apr 2018 16:21:14 GMT
server: Finatra
strict-transport-security: max-age=31536000; includeSubDomains; preload
content-security-policy: upgrade-insecure-requests
access-control-allow-origin: '*'
cache-control: private
ncbi-phid: 644081FF892592C429149881FC4396BF.1.m_3
ncbi-sid: 6A8B33BC89AA0BA0_61BASID
content-type: text/xml; charset=UTF-8
x-ratelimit-limit: '150'
x-ratelimit-remaining: '146'
content-encoding: gzip
set-cookie: ncbi_sid=6A8B33BC89AA0BA0_61BASID; domain=.nih.gov; path=/; expires=Fri,
05 Apr 2019 16:21:14 GMT
x-ua-compatible: IE=Edge
x-xss-protection: 1; mode=block
transfer-encoding: chunked
body:
encoding: UTF-8
string: |-
<?xml version="1.0" ?>
<!DOCTYPE TaxaSet PUBLIC "-//NLM//DTD Taxon, 14th January 2002//EN" "https://www.ncbi.nlm.nih.gov/entrez/query/DTD/taxon.dtd">
<TaxaSet>
</TaxaSet>
recorded_at: 2018-04-05 16:21:14 GMT
recorded_with: vcr/0.0.7.9325
44 changes: 44 additions & 0 deletions tests/fixtures/vcr_cassettes/classification_invalid_ids2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
http_interactions:
- request:
method: get
uri: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=taxonomy&ID=8888888888&api_key=eea6131e94f20ca3f84bb345e8a4f9f4c108
body:
encoding: ''
string: ''
headers:
User-Agent: libcurl/7.54.0 r-curl/3.2 crul/0.5.2
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: Thu, 05 Apr 2018 16:21:14 GMT
server: Finatra
strict-transport-security: max-age=31536000; includeSubDomains; preload
content-security-policy: upgrade-insecure-requests
access-control-allow-origin: '*'
cache-control: private
ncbi-phid: 0EE57C5FD6AF758EECFA3C98D3690CF8.1.m_3
ncbi-sid: D32F37DD656D596E_C797SID
content-type: text/xml; charset=UTF-8
x-ratelimit-limit: '150'
x-ratelimit-remaining: '145'
content-encoding: gzip
set-cookie: ncbi_sid=D32F37DD656D596E_C797SID; domain=.nih.gov; path=/; expires=Fri,
05 Apr 2019 16:21:15 GMT
x-ua-compatible: IE=Edge
x-xss-protection: 1; mode=block
transfer-encoding: chunked
body:
encoding: UTF-8
string: |-
<?xml version="1.0" ?>
<!DOCTYPE TaxaSet PUBLIC "-//NLM//DTD Taxon, 14th January 2002//EN" "https://www.ncbi.nlm.nih.gov/entrez/query/DTD/taxon.dtd">
<TaxaSet>
</TaxaSet>
recorded_at: 2018-04-05 16:21:15 GMT
recorded_with: vcr/0.0.7.9325
196 changes: 196 additions & 0 deletions tests/fixtures/vcr_cassettes/classification_invalid_ids3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
http_interactions:
- request:
method: get
uri: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=taxonomy&ID=3702&api_key=eea6131e94f20ca3f84bb345e8a4f9f4c108
body:
encoding: ''
string: ''
headers:
User-Agent: libcurl/7.54.0 r-curl/3.2 crul/0.5.2
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: Thu, 05 Apr 2018 16:21:15 GMT
server: Finatra
strict-transport-security: max-age=31536000; includeSubDomains; preload
content-security-policy: upgrade-insecure-requests
access-control-allow-origin: '*'
cache-control: private
ncbi-phid: 6BA2F0C898D72FC7C63842EA143832F9.1.m_3
ncbi-sid: 93374FDDBAB1BFB6_DCDCSID
content-type: text/xml; charset=UTF-8
x-ratelimit-limit: '150'
x-ratelimit-remaining: '145'
content-encoding: gzip
set-cookie: ncbi_sid=93374FDDBAB1BFB6_DCDCSID; domain=.nih.gov; path=/; expires=Fri,
05 Apr 2019 16:21:15 GMT
x-ua-compatible: IE=Edge
x-xss-protection: 1; mode=block
transfer-encoding: chunked
body:
encoding: UTF-8
string: |-
<?xml version="1.0" ?>
<!DOCTYPE TaxaSet PUBLIC "-//NLM//DTD Taxon, 14th January 2002//EN" "https://www.ncbi.nlm.nih.gov/entrez/query/DTD/taxon.dtd">
<TaxaSet><Taxon>
<TaxId>3702</TaxId>
<ScientificName>Arabidopsis thaliana</ScientificName>
<OtherNames>
<GenbankCommonName>thale cress</GenbankCommonName>
<CommonName>mouse-ear cress</CommonName>
<CommonName>thale-cress</CommonName>
<Name>
<ClassCDE>authority</ClassCDE>
<DispName>Arabidopsis thaliana (L.) Heynh.</DispName>
</Name>
<Name>
<ClassCDE>misspelling</ClassCDE>
<DispName>Arabidopsis thaliana (thale cress)</DispName>
</Name>
<Name>
<ClassCDE>misspelling</ClassCDE>
<DispName>Arabidopsis_thaliana</DispName>
</Name>
<Name>
<ClassCDE>misspelling</ClassCDE>
<DispName>Arbisopsis thaliana</DispName>
</Name>
<Name>
<ClassCDE>misspelling</ClassCDE>
<DispName>thale kress</DispName>
</Name>
</OtherNames>
<ParentTaxId>3701</ParentTaxId>
<Rank>species</Rank>
<Division>Plants and Fungi</Division>
<GeneticCode>
<GCId>1</GCId>
<GCName>Standard</GCName>
</GeneticCode>
<MitoGeneticCode>
<MGCId>1</MGCId>
<MGCName>Standard</MGCName>
</MitoGeneticCode>
<Lineage>cellular organisms; Eukaryota; Viridiplantae; Streptophyta; Streptophytina; Embryophyta; Tracheophyta; Euphyllophyta; Spermatophyta; Magnoliophyta; Mesangiospermae; eudicotyledons; Gunneridae; Pentapetalae; rosids; malvids; Brassicales; Brassicaceae; Camelineae; Arabidopsis</Lineage>
<LineageEx>
<Taxon>
<TaxId>131567</TaxId>
<ScientificName>cellular organisms</ScientificName>
<Rank>no rank</Rank>
</Taxon>
<Taxon>
<TaxId>2759</TaxId>
<ScientificName>Eukaryota</ScientificName>
<Rank>superkingdom</Rank>
</Taxon>
<Taxon>
<TaxId>33090</TaxId>
<ScientificName>Viridiplantae</ScientificName>
<Rank>kingdom</Rank>
</Taxon>
<Taxon>
<TaxId>35493</TaxId>
<ScientificName>Streptophyta</ScientificName>
<Rank>phylum</Rank>
</Taxon>
<Taxon>
<TaxId>131221</TaxId>
<ScientificName>Streptophytina</ScientificName>
<Rank>subphylum</Rank>
</Taxon>
<Taxon>
<TaxId>3193</TaxId>
<ScientificName>Embryophyta</ScientificName>
<Rank>no rank</Rank>
</Taxon>
<Taxon>
<TaxId>58023</TaxId>
<ScientificName>Tracheophyta</ScientificName>
<Rank>no rank</Rank>
</Taxon>
<Taxon>
<TaxId>78536</TaxId>
<ScientificName>Euphyllophyta</ScientificName>
<Rank>no rank</Rank>
</Taxon>
<Taxon>
<TaxId>58024</TaxId>
<ScientificName>Spermatophyta</ScientificName>
<Rank>no rank</Rank>
</Taxon>
<Taxon>
<TaxId>3398</TaxId>
<ScientificName>Magnoliophyta</ScientificName>
<Rank>no rank</Rank>
</Taxon>
<Taxon>
<TaxId>1437183</TaxId>
<ScientificName>Mesangiospermae</ScientificName>
<Rank>no rank</Rank>
</Taxon>
<Taxon>
<TaxId>71240</TaxId>
<ScientificName>eudicotyledons</ScientificName>
<Rank>no rank</Rank>
</Taxon>
<Taxon>
<TaxId>91827</TaxId>
<ScientificName>Gunneridae</ScientificName>
<Rank>no rank</Rank>
</Taxon>
<Taxon>
<TaxId>1437201</TaxId>
<ScientificName>Pentapetalae</ScientificName>
<Rank>no rank</Rank>
</Taxon>
<Taxon>
<TaxId>71275</TaxId>
<ScientificName>rosids</ScientificName>
<Rank>subclass</Rank>
</Taxon>
<Taxon>
<TaxId>91836</TaxId>
<ScientificName>malvids</ScientificName>
<Rank>no rank</Rank>
</Taxon>
<Taxon>
<TaxId>3699</TaxId>
<ScientificName>Brassicales</ScientificName>
<Rank>order</Rank>
</Taxon>
<Taxon>
<TaxId>3700</TaxId>
<ScientificName>Brassicaceae</ScientificName>
<Rank>family</Rank>
</Taxon>
<Taxon>
<TaxId>980083</TaxId>
<ScientificName>Camelineae</ScientificName>
<Rank>tribe</Rank>
</Taxon>
<Taxon>
<TaxId>3701</TaxId>
<ScientificName>Arabidopsis</ScientificName>
<Rank>genus</Rank>
</Taxon>
</LineageEx>
<Properties>
<Property>
<PropName>pgcode</PropName>
<PropValueInt>11</PropValueInt>
</Property>
</Properties>
<CreateDate>1995/02/27 09:24:00</CreateDate>
<UpdateDate>2017/07/06 17:40:43</UpdateDate>
<PubDate>1992/11/10 00:00:00</PubDate>
</Taxon>
</TaxaSet>
recorded_at: 2018-04-05 16:21:15 GMT
recorded_with: vcr/0.0.7.9325
3 changes: 3 additions & 0 deletions tests/testthat/helper-taxizedb.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# set up vcr
library("vcr")
invisible(vcr::vcr_configure(dir = "../fixtures/vcr_cassettes"))
14 changes: 8 additions & 6 deletions tests/testthat/test-children.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ test_that("unambiguous children", {
# taxizedb::children(3702, db='ncbi'),
# taxize::children(3702, db='ncbi')
# )
expect_equal(
taxizedb::children(3701, db='ncbi'),
taxize::children(3701, db='ncbi')
)
vcr::use_cassette("children_unambiguous", {
expect_equal(
taxizedb::children(3701, db='ncbi'),
taxize::children(3701, db='ncbi')
)
}, preserve_exact_body_bytes = FALSE)

## TODO: these are not currently equal
## once changes in taxize are sorted out, we can restore this test
Expand All @@ -23,7 +25,7 @@ test_that("unambiguous children", {
# )
})

test_that("ambiguous NCBI children", {
# test_that("ambiguous NCBI children", {
## TODO: these are not currently equal
## once changes in taxize are sorted out, we can restore this test
# expect_equal(
Expand All @@ -33,7 +35,7 @@ test_that("ambiguous NCBI children", {
# subset(childtaxa_rank != 'species') %>%
# magrittr::set_rownames(NULL)
# )
})
# })

test_that("missing values are consistent with taxize", {
empty_df <- data.frame(
Expand Down
Loading

0 comments on commit 9fa5420

Please sign in to comment.