From 898d598bcbb022ac767e0105e868798130f2c74c Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 13 Oct 2020 15:10:03 +0200 Subject: Adapt to changes in webchem Unfortunately, tests only pass sometimes, it seems PubChem is not always responding --- ChangeLog | 8 ++++++++ DESCRIPTION | 1 - GNUmakefile | 3 ++- R/chent.R | 10 +++------- test.log | 18 +++++------------- tests/testthat/test_pai.R | 8 ++++---- 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 77934da..011b28d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +commit 6937e41d317b953d8246203814500166dbe89470 +Author: Johannes Ranke +Date: 2020-10-13 11:26:03 +0200 + + Temporarily remove @example tags + + Due to r-lib/roxygen2#1158 + commit c8bfe56bd627e1945815631ce5c2ac27333fa246 Author: Johannes Ranke Date: 2019-07-15 14:45:52 +0200 diff --git a/DESCRIPTION b/DESCRIPTION index f19c36b..a00e9a4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,6 +27,5 @@ License: GPL LazyLoad: yes LazyData: yes Encoding: UTF-8 -VignetteBuilder: knitr URL: https://github.com/jranke/chents RoxygenNote: 7.1.1.9000 diff --git a/GNUmakefile b/GNUmakefile index fdf9b80..c9975a9 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -50,6 +50,7 @@ winbin: $(WINBIN) test: build @echo "Running testthat tests..." "$(R_HOME)/bin/Rscript" -e 'library(devtools); devtools::test()' 2>&1 | tee test.log + sed -i -e "s/\r.*\r//" test.log @echo "DONE." quickcheck: build @@ -59,7 +60,7 @@ quickcheck: build check: build @echo "Running CRAN check..." - _R_CHECK_CRAN_INCOMING_REMOTE_=false "$(R_HOME)/bin/R" CMD check --as-cran $(TGZ) + _R_CHECK_CRAN_INCOMING_REMOTE_=false "$(R_HOME)/bin/R" CMD check --as-cran $(TGZ) --no-tests @echo "DONE." install: build diff --git a/R/chent.R b/R/chent.R index 75b6098..b2c2e4a 100644 --- a/R/chent.R +++ b/R/chent.R @@ -110,15 +110,11 @@ chent <- R6Class("chent", try_pubchem = function(query, from = 'name') { message("PubChem:") if (missing(query)) query <- self$identifier - pubchem_result = webchem::get_cid(query, from = from) + pubchem_result = webchem::get_cid(query, from = from, match = "first") - if (is.na(pubchem_result[[1]][1])) { + if (is.na(pubchem_result[[1, "cid"]])) { message("Query ", query, " did not give results at PubChem") } else { - n_results = length(pubchem_result[[1]]) - if (n_results > 1) { - warning("Found ", n_results, " entries in PubChem, using the first one.") - } self$get_pubchem(pubchem_result[[1, "cid"]]) } }, @@ -511,7 +507,7 @@ pai <- R6Class("pai", if (!missing(iso) & alanwood) { message("alanwood.net:") - aw_result = webchem::aw_query(identifier, type = "commonname") + aw_result = webchem::aw_query(identifier, from = "name") # Use first element of list, as we passed a query of length one if (is.na(aw_result[[1]][1])) { diff --git a/test.log b/test.log index 587b665..34cf63b 100644 --- a/test.log +++ b/test.log @@ -1,20 +1,12 @@ +Loading required package: usethis Loading chents Attaching package: ‘testthat’ -The following objects are masked from ‘package:devtools’: +The following object is masked from ‘package:devtools’: - setup, test_file + test_file Testing chents -✔ | OK F W S | Context - ⠏ | 0 | Generation of chent objects ⠋ | 1 | Generation of chent objects ⠙ | 2 | Generation of chent objects ⠹ | 3 | Generation of chent objects ⠸ | 4 | Generation of chent objects ⠼ | 5 | Generation of chent objects ⠴ | 6 | Generation of chent objects ✔ | 6 | Generation of chent objects [5.3 s] - ⠏ | 0 | Generation of pai objects ⠋ | 1 | Generation of pai objects ⠙ | 2 | Generation of pai objects ⠹ | 3 | Generation of pai objects ⠸ | 4 | Generation of pai objects ⠼ | 5 | Generation of pai objects ⠴ | 6 | Generation of pai objects ⠦ | 7 | Generation of pai objects ⠧ | 8 | Generation of pai objects ⠇ | 9 | Generation of pai objects ✔ | 9 | Generation of pai objects [6.8 s] - -══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 12.1 s - -OK: 15 -Failed: 0 -Warnings: 0 -Skipped: 0 +✔ | OK F W S | Context + ⠏ | 0 | Generation of chent objects ⠋ | 1 | Generation of chent objects \ No newline at end of file diff --git a/tests/testthat/test_pai.R b/tests/testthat/test_pai.R index de1f235..368876e 100644 --- a/tests/testthat/test_pai.R +++ b/tests/testthat/test_pai.R @@ -4,9 +4,9 @@ require(testthat) context("Generation of pai objects") -test_that("a pai object is correctly generated from an ambiguous name, with warning", { - expect_warning(glyphosate <- pai$new("glyphosate", chyaml = FALSE)) - expect_warning(pai$new("benzalkonium chloride", chyaml = FALSE)) +test_that("a pai object is correctly generated from an ambiguous name", { + glyphosate <- pai$new("glyphosate", chyaml = FALSE) + expect_message(pai$new("benzalkonium chloride", chyaml = FALSE), "did not give results") expect_equivalent(glyphosate$alanwood$cas, "1071-83-6") expect_equivalent(glyphosate$alanwood$formula, "C3H8NO5P") @@ -15,7 +15,7 @@ test_that("a pai object is correctly generated from an ambiguous name, with warn ik = "XDDAORKBJWWYJS-UHFFFAOYSA-N" attr(ik, "source") <- c("alanwood", "pubchem") expect_equal(glyphosate$inchikey, ik) - expect_equivalent(round(glyphosate$mw, 2), 169.07) + expect_equivalent(round(glyphosate$mw, 2), 169.07) smiles <- "C(C(=O)O)NCP(=O)(O)O" expect_equal(glyphosate$smiles[["PubChem_Canonical"]], smiles) }) -- cgit v1.2.1