Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
collectr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DREAL Pays de la Loire
Centre de Services de la Donnée
ADL
collectr
Commits
029780c0
Commit
029780c0
authored
4 months ago
by
ronan.vignard
Browse files
Options
Downloads
Patches
Plain Diff
Création des tests pour fix_encoding_variable()
parent
4f3b2548
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!67
Passage en version 0.1.6
,
!66
Intégration de la fonction download_files_from_list()
,
!65
Correction d'un bug + création des tests pour fix_encoding_variable()
Pipeline
#537642
passed with warnings
4 months ago
Stage: build
Stage: test
Stage: pkgdown
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dev/0-dev_history.Rmd
+2
-0
2 additions, 0 deletions
dev/0-dev_history.Rmd
tests/testthat/test-fix_encoding_variable.R
+31
-0
31 additions, 0 deletions
tests/testthat/test-fix_encoding_variable.R
with
33 additions
and
0 deletions
dev/0-dev_history.Rmd
+
2
−
0
View file @
029780c0
...
@@ -80,6 +80,7 @@ usethis::use_r("close_all_connections")
...
@@ -80,6 +80,7 @@ usethis::use_r("close_all_connections")
usethis::use_r("create_dummy")
usethis::use_r("create_dummy")
usethis::use_r("create_schema")
usethis::use_r("create_schema")
usethis::use_r("download_and_extract_wfs")
usethis::use_r("download_and_extract_wfs")
usethis::use_r("fix_encoding_variable")
usethis::use_r("format_colnames")
usethis::use_r("format_colnames")
usethis::use_r("format_filepath")
usethis::use_r("format_filepath")
usethis::use_r("get_variable_completion_rate")
usethis::use_r("get_variable_completion_rate")
...
@@ -104,6 +105,7 @@ usethis::use_test("close_all_connections")
...
@@ -104,6 +105,7 @@ usethis::use_test("close_all_connections")
usethis::use_test("create_dummy")
usethis::use_test("create_dummy")
usethis::use_test("create_schema")
usethis::use_test("create_schema")
usethis::use_test("download_and_extract_wfs")
usethis::use_test("download_and_extract_wfs")
usethis::use_test("fix_encoding_variable")
usethis::use_test("format_colnames")
usethis::use_test("format_colnames")
usethis::use_test("format_filepath")
usethis::use_test("format_filepath")
usethis::use_test("get_variable_completion_rate")
usethis::use_test("get_variable_completion_rate")
...
...
This diff is collapsed.
Click to expand it.
tests/testthat/test-fix_encoding_variable.R
0 → 100644
+
31
−
0
View file @
029780c0
test_that
(
"fix_encoding_variable works"
,
{
# Création d'un dataframe d'exemple avec encodage ISO-8859-1
data_test
<-
data.frame
(
id
=
1
:
3
,
libelle
=
c
(
"Établissement A"
,
"Forêt B"
,
"Île C"
),
stringsAsFactors
=
FALSE
)
# Simuler un encodage ISO-8859-1
data_test
$
libelle
<-
iconv
(
data_test
$
libelle
,
from
=
"UTF-8"
,
to
=
"ISO-8859-1"
)
# Vérification avant correction
# expect_true(all(Encoding(data_test$libelle) == "latin1"))
# Application de la correction
data_test_corrige
<-
fix_encoding_variable
(
data_test
,
"libelle"
)
# Vérification après correction
expect_true
(
all
(
Encoding
(
data_test_corrige
$
libelle
)
==
"UTF-8"
))
# Vérification du contenu inchangé
expect_equal
(
data_test_corrige
$
libelle
,
c
(
"Établissement A"
,
"Forêt B"
,
"Île C"
))
})
test_that
(
"fix_encoding_variable fails"
,
{
data_test
<-
data.frame
(
id
=
1
:
3
,
nom
=
c
(
"A"
,
"B"
,
"C"
))
# Vérifie que la fonction renvoie une erreur
expect_error
(
fix_encoding_variable
(
data_test
,
"libelle"
),
"La variable libelle n'existe pas dans le dataframe."
)
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment