Skip to content

Commit cf1fd3b

Browse files
correctifs
1 parent 28f2f36 commit cf1fd3b

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

R/millesimesDisponibles.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
millesimesDisponibles <- function(donnees) {
1111
## check the parameter donnees takes a valid value
1212
donnees <- toupper(donnees)
13-
liste_nom <- unlist(lapply(ld, function(x) return(x$nom)))
13+
liste_nom <- toupper(unlist(lapply(ld, function(x) return(x$nom))))
1414
if (!donnees %in% liste_nom)
1515
stop("Le param\u00e8tre donnees est mal sp\u00e9cifi\u00e9, la valeur n'est pas r\u00e9f\u00e9renc\u00e9e")
1616
liste_possible <- ld[which(liste_nom == donnees)]

R/utile.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
infosDonnees <- function(donnees, date = NULL, silencieux = FALSE) {
2222

2323
donnees <- toupper(donnees) # pour rendre insensible à la casse
24-
liste_nom <- vapply(ld, `[[`, "nom", FUN.VALUE = character(1))
24+
liste_nom <- toupper(vapply(ld, `[[`, "nom", FUN.VALUE = character(1)))
2525
res <- ld[liste_nom == donnees]
2626

2727
# 1 - identifiant introuvable

R/zzz.R

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
.onLoad <- function(libname, pkgname) {
22
#data(liste_donnees)
3-
if (curl::has_internet())
4-
ld_melodi <- httr::GET("https://minio.lab.sspcloud.fr/pierrelamarche/melodi/liste_donnees.json")
5-
assign("ld", c(ld, jsonlite::fromJSON(httr::content(ld_melodi, as = "text", encoding = "utf-8"),
6-
simplifyDataFrame = FALSE)),
3+
if (curl::has_internet()) {
4+
requete_melodi <- httr::GET("https://minio.lab.sspcloud.fr/pierrelamarche/melodi/liste_donnees.json")
5+
ld_melodi <- jsonlite::fromJSON(httr::content(requete_melodi, as = "text", encoding = "utf-8"),
6+
simplifyDataFrame = FALSE)
7+
ld_melodi <- lapply(ld_melodi, function(x) {
8+
within(x, {
9+
if (!is.null(x$date_ref))
10+
date_ref <- as.Date(date_ref, format = "%Y-%m-%d")
11+
if(!is.null(x$separateur))
12+
separateur <- paste0("quote(\"", separateur, "\")")
13+
})
14+
}
15+
)
16+
assign("ld", c(ld, ld_melodi),
717
envir = asNamespace("doremifasol")
8-
)
18+
)
19+
}
920
}

tests/testthat/test_liste_donnees.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ test_that("pas de valeurs incongrues", {
2323

2424
# lien (motif, pas existence)
2525
url_pattern <- "^https://www.insee.fr/fr/statistiques/fichier/\\d{5,}/.+\\.(zip|xls|xlsx|parquet)$"
26-
api_url_pattern <- "^https://api.insee.fr/entreprises/sirene(/V3.11)?/sire[nt](/(liensSuccession|nonDiffusibles))?$"
26+
api_sirene_url_pattern <- "^https://api.insee.fr/entreprises/sirene(/V3.11)?/sire[nt](/(liensSuccession|nonDiffusibles))?$"
27+
api_melodi_url_pattern <- "^https://api.insee.fr/melodi/.*$"
2728
expect_true(
28-
all(grepl(paste0(url_pattern, "|", api_url_pattern), df_ld$lien))
29+
all(grepl(paste0(url_pattern, "|", api_sirene_url_pattern, "|", api_melodi_url_pattern), df_ld$lien))
2930
)
3031

3132
# type
@@ -43,7 +44,7 @@ test_that("pas de valeurs incongrues", {
4344

4445
# big_zip
4546
expect_true(
46-
all(df_ld$big_zip[df_ld$zip] %in% c(TRUE, FALSE))
47+
with(df_ld, all(big_zip[zip] %in% c(TRUE, FALSE)))
4748
)
4849

4950
# premiere_ligne / derniere_ligne
@@ -64,3 +65,4 @@ test_that("pas de valeurs incongrues", {
6465
)
6566

6667
})
68+

0 commit comments

Comments
 (0)