tests/testthat/test_url.R

# Copyright 2017-2019 Gabriele Sales <gabriele.sales@unipd.it>
#
#
# This file is part of graphite.
#
# graphite is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License
# version 3 as published by the Free Software Foundation.
#
# graphite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with graphite. If not, see <http://www.gnu.org/licenses/>.

suppressPackageStartupMessages(library(httr))

context("Pathway URLs")

test_that("each pathway database links to valid pathway URLs", {
  skip_on_bioc()

  dbs <- pathwayDatabases()
  species <- "hsapiens"

  dbs <- as.character(dbs[dbs$species == species, "database"])

  # NCI pathways are now hosted on www.ndexbio.org, which uses JavaScript to
  # load network.s We cannot reliably test such URLs here.
  dbs <- setdiff(dbs, "nci")

  for (db in dbs) {
    p <- sample(pathways(species, db), 1)[[1]]
    r <- HEAD(pathwayURL(p), timeout(30))
    expect_equal(http_status(r)$category, "Success",
                 info = paste0(db, "(", pathwayTitle(p), ")"))
  }
})

Try the graphite package in your browser

Any scripts or data that you put into this service are public.

graphite documentation built on Nov. 8, 2020, 8:12 p.m.