File: test_Namespaces.R

package info (click to toggle)
r-cran-rsdmx 0.5.7%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 940 kB
  • sloc: makefile: 2
file content (32 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# test_Namespaces.R
# Author: Emmanuel Blondel <emmanuel.blondel1@gmail.com>
#
# Description: Unit tests for Namespace functions
#=======================
require(rsdmx, quietly = TRUE)
require(testthat)
context("Namespaces")

test_that("getNamespaces",{
  file <- system.file("extdata", "SDMXGenericDataExample_2.0.xml", package = "rsdmx")
  sdmx <- readSDMX(file, isURL = FALSE)
  
  namespaces <- getNamespaces(sdmx)
  expect_is(namespaces, "data.frame")
  expect_equal("uri", colnames(namespaces))
  expect_equal(11L, nrow(namespaces))
})

test_that("findNamespace",{
  file <- system.file("extdata", "SDMXGenericDataExample_2.0.xml", package = "rsdmx")
  sdmx <- readSDMX(file, isURL = FALSE)
  
  namespaces <- getNamespaces(sdmx)
  namespace <- findNamespace(namespaces, "generic")
  expect_is(namespace, "character")
  expect_equal(1L, length(namespace))
  expect_equal("http://www.SDMX.org/resources/SDMXML/schemas/v2_0/generic",
               as.character(namespace))
  
})