File: test_Header.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 (49 lines) | stat: -rw-r--r-- 1,745 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# test_Header.R
# Author: Emmanuel Blondel <emmanuel.blondel1@gmail.com>
#
# Description: Unit tests for SDMX Header methods
#=======================
require(rsdmx, quietly = TRUE)
require(testthat)
context("SDMXHeader")

test_that("SDMXHeader - 2.0",{
  
  file <- system.file("extdata", "SDMXMessageExample_2.0.xml", package = "rsdmx")
  xmlObj <- xmlParse(file)
  ns <- namespaces.SDMX(xmlObj)
	obj = SDMXHeader(xmlObj, ns)
	expect_is(obj, "SDMXHeader")
	expect_equal(obj@ID, "data.organization.org")
	expect_false(obj@Test)
	expect_false(obj@Truncated)
	expect_equal(obj@Name, "thename")
	expect_equal(obj@Prepared, as.POSIXlt(strptime("2014-03-02T16:29:26", format = "%Y-%m-%dT%H:%M:%S")))
	expect_is(obj@Sender, "list")
	expect_equal(obj@Sender$id, "ORGANIZATION")
	expect_equal(obj@Sender$name$en, "Organization")
	expect_equal(obj@Sender$name$fr, "Organisation")
	expect_equal(obj@Receiver$id, NA)
	expect_equal(obj@ReportingBegin, as.POSIXlt(strptime(ISOdate(2000,1,1), format = "%Y-%m-%d")))
	expect_equal(obj@ReportingEnd, as.POSIXlt(strptime(ISOdate(2008,12,31), format = "%Y-%m-%d")))
})


test_that("SDMXHeader - 2.1",{
  
  file <- system.file("extdata", "SDMXMessageExample_2.1.xml", package = "rsdmx")
  xmlObj <- xmlParse(file)
  ns <- namespaces.SDMX(xmlObj)
  obj = SDMXHeader(xmlObj, ns)
  expect_is(obj, "SDMXHeader")
  expect_equal(obj@ID, "176ea8e40bfc189c8113edf292a3abb4")
  expect_false(obj@Test)
  expect_equal(obj@Prepared, as.POSIXlt(strptime("2014-07-18T07:04:39", format = "%Y-%m-%dT%H:%M:%S")))
  expect_is(obj@Sender, "list")
  expect_equal(obj@Sender$id, "ESTAT")
  expect_equal(obj@Sender$name$en, "Eurostat")
  expect_equal(obj@Receiver$id, "RECEIVER")

})