Skip to content

Commit

Permalink
Merge pull request #104 from analytics-ufcg/822-bug-prop-senado
Browse files Browse the repository at this point in the history
822 bug prop senado
  • Loading branch information
thayannevls authored Feb 21, 2019
2 parents e2ce9c8 + 1f075f9 commit b7c0112
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
33 changes: 22 additions & 11 deletions R/proposicoes.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,29 @@ fetch_proposicao_senado <- function(id) {
ifelse("UfAutor" %in% names(.), paste("/", UfAutor), "")))

proposicao_specific_assunto <-
proposicao_data %>%
magrittr::extract2("Assunto") %>%
magrittr::extract2("AssuntoEspecifico") %>%
tibble::as.tibble() %>%
dplyr::rename(assunto_especifico = Descricao, codigo_assunto_especifico = Codigo)

proposicao_data$Assunto$AssuntoEspecifico %>%
tibble::as.tibble()
if (nrow(proposicao_specific_assunto) == 0) {
proposicao_specific_assunto <-
tibble::tribble(~ codigo_assunto_especifico, ~ assunto_especifico,
0, "Nao especificado")
}else {
proposicao_specific_assunto <-
proposicao_specific_assunto %>%
dplyr::rename(assunto_especifico = Descricao, codigo_assunto_especifico = Codigo)
}
proposicao_general_assunto <-
proposicao_data %>%
magrittr::extract2("Assunto") %>%
magrittr::extract2("AssuntoGeral") %>%
tibble::as.tibble() %>%
dplyr::rename(assunto_geral = Descricao, codigo_assunto_geral = Codigo)
proposicao_data$Assunto$AssuntoGeral %>%
tibble::as.tibble()
if (nrow(proposicao_general_assunto) == 0) {
proposicao_general_assunto <-
tibble::tribble(~ codigo_assunto_geral, ~ assunto_geral,
0, "Nao especificado")
}else {
proposicao_general_assunto <-
proposicao_general_assunto %>%
dplyr::rename(assunto_geral = Descricao, codigo_assunto_geral = Codigo)
}

proposicao_source <-
proposicao_data %>%
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test_proposicoes.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pec_241 <<- fetch_proposicao_camara(siglaTipo = "PEC", numero = 241, ano = 2016,
pec_241_id <<- fetch_id_proposicao_camara("PEC", 241, 2016)
pec_241_por_id <<- fetch_proposicao_camara(pec_241_id)
pls_91341 <<- fetch_proposicao_senado(91341)
pls_1489 <<- fetch_proposicao_senado(1489)
votacoes_pec_241 <<- fetch_votacoes(pec_241_id)
relacionadas_pec_241 <<- fetch_relacionadas(pec_241_id)
deferimento <- fetch_deferimento(c("102343", "109173", "115853"))
Expand Down Expand Up @@ -50,14 +51,18 @@ test_that("fetch_proposicao_camara() usando ID", {
test_that("fetch_proposicao_senado()", {
expect_true(all(sapply(pls_91341, class) %in% .COLNAMES_PROPOSICAO_SENADO))
expect_true(nrow(pls_91341) != 0)
expect_true(all(sapply(pls_1489, class) %in% .COLNAMES_PROPOSICAO_SENADO))
expect_true(nrow(pls_1489) != 0)
})

test_that("fetch_proposicao_senado() not empty", {
expect_true(nrow(pls_91341) != 0)
expect_true(nrow(pls_1489) != 0)
})

test_that("fetch_proposicao_senado() is dataframe", {
expect_true(is.data.frame(pls_91341))
expect_true(is.data.frame(pls_1489))
})

test_that("fetch_votacoes()", {
Expand Down

0 comments on commit b7c0112

Please sign in to comment.