tests/testthat/test_Properties.R

context("Property/ies")

test_that("Property constructors", {
    soprops <- properties("so")
    ont <- Ontology("so")
    soprops2 <- properties(ont)
    ## note that this is true only of the order of the two requests is
    ## the same. This seems to be the case here, pronably because
    ## there are relatively rew results. Might need to implement an
    ## all.equal method though.
    expect_identical(soprops, soprops2)

    trm <- term("uberon", "UBERON_0002107")
    p <- properties(trm)
    expect_is(p, "Properties")
    ## expect_identical(length(p), 11L)

    expect_identical(termId(p), sapply(p@x, "slot", "obo_id"))

    trm2 <- term("uberon", "UBERON_0002108")
    trm3 <- term("uberon", "UBERON_0000002")

    trmlst <- c(trm, trm2, trm3)
    names(trmlst) <- sapply(trmlst, termId)
    trms <- rols:::Terms(x = trmlst)
    
    pl <- properties(trms)
    expect_is(pl, "list")
    expect_identical(length(pl), 3L)

    so <- terms(ont)
    k <- c("SO:0000579", "SO:0000833", "SO:0000578", "SO:0000011",
           "SO:0000577", "SO:0000628", "SO:0001431", "SO:0000704",
           "SO:0000976", "SO:0000576")
    
    pl <- properties(so[k])

    ## expect_message(x <- properties(so[k[1]]), "No properties for term SO:0000579")
    ## expect_null(x[[1]])
    ## x <- properties(so[k])
    ## expect_identical(sum(sapply(x, is.null)), 7L)
})


test_that("Property/ies show", {
    expect_null(show(properties("so")))
    trm <- term("uberon", "UBERON_0002107")
    p <- properties(trm)
    expect_null(show(p))
    expect_null(show(p[[1]]))
})

test_that("iterating over next property", {
    go <- Ontology("go")
    p1 <- properties(go)
    p2 <- properties(go, pagesize = 10)
    expect_identical(p1, p2)
})

Try the rols package in your browser

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

rols documentation built on April 1, 2021, 6:01 p.m.