Nothing
test_that("sei_build_envelope produz o formato do SEI", {
env <- sei_build_envelope("listarUnidades", list(
SiglaSistema = "HORTENSIAS",
IdentificacaoServico = "publicacao"
))
expect_true(grepl('xmlns:sei="Sei"', env, fixed = TRUE))
expect_true(grepl("soapenv:encodingStyle", env, fixed = TRUE))
expect_true(grepl('<sei:listarUnidades', env, fixed = TRUE))
expect_true(grepl('<SiglaSistema xsi:type="xsd:string">HORTENSIAS</SiglaSistema>',
env, fixed = TRUE))
# deve ser XML válido
expect_s3_class(xml2::read_xml(env), "xml_document")
})
test_that("escape de caracteres reservados de XML", {
expect_equal(sei_xml_escape("a & b < c > d"), "a & b < c > d")
env <- sei_build_envelope("op", list(Campo = "A & B <x>"))
expect_true(grepl("A & B <x>", env, fixed = TRUE))
expect_s3_class(xml2::read_xml(env), "xml_document")
})
test_that("parâmetros NULL são omitidos e NA viram xsi:nil", {
env <- sei_build_envelope("op", list(A = "1", B = NULL, C = NA))
expect_true(grepl("<A xsi:type=\"xsd:string\">1</A>", env, fixed = TRUE))
expect_false(grepl("<B", env, fixed = TRUE))
expect_true(grepl("<C xsi:nil=\"true\"/>", env, fixed = TRUE))
})
test_that("estruturas aninhadas e arrays de <item>", {
env <- sei_build_envelope("gerarProcedimento", list(
Procedimento = list(IdTipoProcedimento = "100", Especificacao = "x"),
Assuntos = list(
list(CodigoEstruturado = "00.01"),
list(CodigoEstruturado = "00.02")
)
))
doc <- xml2::read_xml(env)
# estrutura aninhada
expect_equal(
xml2::xml_text(xml2::xml_find_first(doc, "//*[local-name()='IdTipoProcedimento']")),
"100"
)
# array com 2 itens
items <- xml2::xml_find_all(doc, "//*[local-name()='Assuntos']/*[local-name()='item']")
expect_length(items, 2)
})
test_that("sei_config resolve valores e e generico (sem url default)", {
cfg <- sei_config(sigla_sistema = "ABC", identificacao_servico = "k")
expect_s3_class(cfg, "sei_config")
expect_equal(cfg$sigla_sistema, "ABC")
expect_equal(cfg$identificacao_servico, "k")
# sem URL embutida: pacote serve a qualquer instalacao do SEI
expect_equal(cfg$sei_url, "")
# url e configuravel (qualquer servidor)
cfg2 <- sei_config(sei_url = "https://sei.exemplo.gov.br/sei/ws/SeiWS.php")
expect_equal(cfg2$sei_url, "https://sei.exemplo.gov.br/sei/ws/SeiWS.php")
})
test_that("sei_call exige sei_url definido", {
expect_error(
sei_call("listarUnidades", config = sei_config(sigla_sistema = "X",
identificacao_servico = "Y")),
"URL do Web Service"
)
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.