From 1035d4bfce3ffe16173267552d9d56faff78db26 Mon Sep 17 00:00:00 2001 From: lfenzo Date: Sun, 21 Jan 2024 19:18:50 -0300 Subject: [PATCH] test: change order of testsets --- docs/src/developer_guide/data_interface.md | 6 +- src/Impostor.jl | 6 +- src/core/data_interface.jl | 51 ++++++------ src/data/identity/prefix/ar_AA.csv | 9 +++ src/data/identity/prefix/ar_AE.csv | 5 ++ src/data/identity/prefix/ar_BH.csv | 5 ++ src/data/identity/prefix/ar_EG.csv | 5 ++ src/data/identity/prefix/ar_JO.csv | 5 ++ src/data/identity/prefix/ar_PS.csv | 9 +++ src/data/identity/prefix/ar_SA.csv | 9 +++ src/data/identity/prefix/az_AZ.csv | 4 + src/data/identity/prefix/bg_BG.csv | 4 + src/data/identity/prefix/bn_BD.csv | 10 +++ src/data/identity/prefix/bs_BA.csv | 5 ++ src/data/identity/prefix/cs_CZ.csv | 12 +++ src/data/identity/prefix/da_DK.csv | 5 ++ src/data/identity/prefix/de_AT.csv | 7 ++ src/data/identity/prefix/de_CH.csv | 4 + src/data/identity/prefix/de_DE.csv | 7 ++ src/data/identity/prefix/dk_DK.csv | 5 ++ src/data/identity/prefix/el_CY.csv | 5 ++ src/data/identity/prefix/en_AU.csv | 5 ++ src/data/identity/prefix/en_CA.csv | 5 ++ src/data/identity/prefix/en_GB.csv | 5 ++ src/data/identity/prefix/en_IE.csv | 5 ++ src/data/identity/prefix/en_PH.csv | 5 ++ src/data/identity/prefix/en_US.csv | 4 +- src/data/identity/prefix/es_AR.csv | 2 + src/data/identity/prefix/es_CA.csv | 2 + src/data/identity/prefix/es_CL.csv | 7 ++ src/data/identity/prefix/es_CO.csv | 9 +++ src/data/identity/prefix/es_ES.csv | 2 + src/data/identity/prefix/es_MX.csv | 5 ++ src/data/identity/prefix/et_EE.csv | 7 ++ src/data/identity/prefix/fa_IR.csv | 4 + src/data/identity/prefix/fi_FI.csv | 8 ++ src/data/identity/prefix/fil_PH.csv | 5 ++ src/data/identity/prefix/fr_BE.csv | 1 + src/data/identity/prefix/fr_FR.csv | 4 + src/data/identity/prefix/ga_IE.csv | 5 ++ src/data/identity/prefix/hu_HU.csv | 2 + src/data/identity/prefix/id_ID.csv | 17 ++++ src/data/identity/prefix/it_CH.csv | 5 ++ src/data/identity/prefix/it_IT.csv | 3 + src/data/identity/prefix/lb_LU.csv | 5 ++ src/data/identity/prefix/mt_MT.csv | 5 ++ src/data/identity/prefix/ne_NP.csv | 4 + src/data/identity/prefix/no_NO.csv | 2 + src/data/identity/prefix/or_IN.csv | 6 ++ src/data/identity/prefix/pl_PL.csv | 2 + src/data/identity/prefix/pt_BR.csv | 2 + src/data/identity/prefix/pt_PT.csv | 5 ++ src/data/identity/prefix/ru_RU.csv | 3 + src/data/identity/prefix/sk_SK.csv | 5 ++ src/data/identity/prefix/sq_AL.csv | 5 ++ src/data/identity/prefix/th_TH.csv | 53 ++++++++++++ src/data/identity/prefix/tl_PH.csv | 5 ++ src/data/identity/prefix/tr_TR.csv | 12 +++ src/data/identity/prefix/tw_GH.csv | 13 +++ src/data/identity/prefix/uk_UA.csv | 2 + src/data/identity/prefix/vi_VN.csv | 5 ++ src/providers/miscellaneous.jl | 2 + test/data_integrity/test_identity.jl | 56 ++++++------- test/data_integrity/test_localization.jl | 94 +++++++++++----------- test/test_data_interface.jl | 12 +-- test/utils.jl | 17 ---- 66 files changed, 482 insertions(+), 128 deletions(-) create mode 100644 src/data/identity/prefix/ar_AA.csv create mode 100644 src/data/identity/prefix/ar_AE.csv create mode 100644 src/data/identity/prefix/ar_BH.csv create mode 100644 src/data/identity/prefix/ar_EG.csv create mode 100644 src/data/identity/prefix/ar_JO.csv create mode 100644 src/data/identity/prefix/ar_PS.csv create mode 100644 src/data/identity/prefix/ar_SA.csv create mode 100644 src/data/identity/prefix/az_AZ.csv create mode 100644 src/data/identity/prefix/bg_BG.csv create mode 100644 src/data/identity/prefix/bn_BD.csv create mode 100644 src/data/identity/prefix/bs_BA.csv create mode 100644 src/data/identity/prefix/cs_CZ.csv create mode 100644 src/data/identity/prefix/da_DK.csv create mode 100644 src/data/identity/prefix/de_AT.csv create mode 100644 src/data/identity/prefix/de_CH.csv create mode 100644 src/data/identity/prefix/de_DE.csv create mode 100644 src/data/identity/prefix/dk_DK.csv create mode 100644 src/data/identity/prefix/el_CY.csv create mode 100644 src/data/identity/prefix/en_AU.csv create mode 100644 src/data/identity/prefix/en_CA.csv create mode 100644 src/data/identity/prefix/en_GB.csv create mode 100644 src/data/identity/prefix/en_IE.csv create mode 100644 src/data/identity/prefix/en_PH.csv create mode 100644 src/data/identity/prefix/es_AR.csv create mode 100644 src/data/identity/prefix/es_CA.csv create mode 100644 src/data/identity/prefix/es_CL.csv create mode 100644 src/data/identity/prefix/es_CO.csv create mode 100644 src/data/identity/prefix/es_ES.csv create mode 100644 src/data/identity/prefix/es_MX.csv create mode 100644 src/data/identity/prefix/et_EE.csv create mode 100644 src/data/identity/prefix/fa_IR.csv create mode 100644 src/data/identity/prefix/fi_FI.csv create mode 100644 src/data/identity/prefix/fil_PH.csv create mode 100644 src/data/identity/prefix/fr_BE.csv create mode 100644 src/data/identity/prefix/fr_FR.csv create mode 100644 src/data/identity/prefix/ga_IE.csv create mode 100644 src/data/identity/prefix/hu_HU.csv create mode 100644 src/data/identity/prefix/id_ID.csv create mode 100644 src/data/identity/prefix/it_CH.csv create mode 100644 src/data/identity/prefix/it_IT.csv create mode 100644 src/data/identity/prefix/lb_LU.csv create mode 100644 src/data/identity/prefix/mt_MT.csv create mode 100644 src/data/identity/prefix/ne_NP.csv create mode 100644 src/data/identity/prefix/no_NO.csv create mode 100644 src/data/identity/prefix/or_IN.csv create mode 100644 src/data/identity/prefix/pl_PL.csv create mode 100644 src/data/identity/prefix/pt_PT.csv create mode 100644 src/data/identity/prefix/ru_RU.csv create mode 100644 src/data/identity/prefix/sk_SK.csv create mode 100644 src/data/identity/prefix/sq_AL.csv create mode 100644 src/data/identity/prefix/th_TH.csv create mode 100644 src/data/identity/prefix/tl_PH.csv create mode 100644 src/data/identity/prefix/tr_TR.csv create mode 100644 src/data/identity/prefix/tw_GH.csv create mode 100644 src/data/identity/prefix/uk_UA.csv create mode 100644 src/data/identity/prefix/vi_VN.csv diff --git a/docs/src/developer_guide/data_interface.md b/docs/src/developer_guide/data_interface.md index f05570e..1973274 100644 --- a/docs/src/developer_guide/data_interface.md +++ b/docs/src/developer_guide/data_interface.md @@ -2,7 +2,7 @@ ```@docs Impostor._load! -Impostor._provider_loaded -Impostor._content_loaded -Impostor._locale_loaded +Impostor.is_provider_loaded +Impostor.is_content_loaded +Impostor.is_locale_loaded ``` diff --git a/src/Impostor.jl b/src/Impostor.jl index c767f5b..9e1d252 100644 --- a/src/Impostor.jl +++ b/src/Impostor.jl @@ -14,9 +14,9 @@ using Chain export session_locale export setlocale! export resetlocale! -export provider_exists -export content_exists -export locale_exists +export is_provider_available +export is_content_available +export is_locale_available export render_template export render_alphanumeric export render_alphanumeric_range diff --git a/src/core/data_interface.jl b/src/core/data_interface.jl index b6e9847..b81d4c0 100644 --- a/src/core/data_interface.jl +++ b/src/core/data_interface.jl @@ -47,20 +47,20 @@ end """ - provider_exists(p::AbstractString) :: Bool + is_provider_available(p::AbstractString) :: Bool Return whether the provided `p` is available. # Parameters - `p::AbstractString`: provider name """ -@inline function provider_exists(p::AbstractString) :: Bool +@inline function is_provider_available(p::AbstractString) :: Bool return p in readdir(joinpath(ASSETS_ROOT)) end """ - content_exists(p::T, c::T) :: Bool where {T <: AbstractString} + is_content_available(p::T, c::T) :: Bool where {T <: AbstractString} Return whether the content `c` is available for provider `p`. @@ -68,13 +68,13 @@ Return whether the content `c` is available for provider `p`. - `p::AbstractString`: provider name - `c::AbstractString`: content name """ -@inline function content_exists(p::T, c::T) :: Bool where {T <: AbstractString} - return provider_exists(p) && c in readdir(joinpath(ASSETS_ROOT, p)) +@inline function is_content_available(p::T, c::T) :: Bool where {T <: AbstractString} + return is_provider_available(p) && c in readdir(joinpath(ASSETS_ROOT, p)) end """ - locale_exists(p::T, c::T, l::T) :: Bool where {T <: AbstractString} + is_locale_available(p::T, c::T, l::T) :: Bool where {T <: AbstractString} Return whether the provided locale `l` is available for content `c` from provider `p`. @@ -83,9 +83,9 @@ Return whether the provided locale `l` is available for content `c` from provide - `c::AbstractString`: content name - `l::AbstractString`: locale name """ -@inline function locale_exists(p::T, c::T, l::T) :: Bool where {T <: AbstractString} +@inline function is_locale_available(p::T, c::T, l::T) :: Bool where {T <: AbstractString} return ( - content_exists(p, c) + is_content_available(p, c) && l * ".csv" in readdir(joinpath(ASSETS_ROOT, p, c)) ) end @@ -93,36 +93,36 @@ end """ - _provider_loaded(d::DataContainer, provider::AbstractString) :: Bool + is_provider_loaded(d::DataContainer, provider::AbstractString) :: Bool Return whether the DataContainer `d` has already loaded the information associated to the content `c`. """ -@inline function _provider_loaded(d::DataContainer, provider::AbstractString) :: Bool +@inline function is_provider_loaded(d::DataContainer, provider::AbstractString) :: Bool return haskey(d.data, provider) end """ - _content_loaded(d::DataContainer, provider::T, content::T) :: Bool + is_content_loaded(d::DataContainer, provider::T, content::T) :: Bool Return whether the DataContainer `d` has already loaded the information associated to the content `c` from provider `p`. """ -@inline function _content_loaded(d::DataContainer, provider::T, content::T) :: Bool where {T <: AbstractString} - return _provider_loaded(d, provider) && haskey(d.data[provider], content) +@inline function is_content_loaded(d::DataContainer, provider::T, content::T) :: Bool where {T <: AbstractString} + return is_provider_loaded(d, provider) && haskey(d.data[provider], content) end """ - _locale_loaded(d::DataContainer, provider::T, content::T, locale::T) :: Bool + is_locale_loaded(d::DataContainer, provider::T, content::T, locale::T) :: Bool Return whether the DataContainer `d` has already loaded the information associated to the content `c` from provider `p` related to locale `l`. """ -@inline function _locale_loaded(d::DataContainer, provider::T, content::T, locale::T) :: Bool where {T <: AbstractString} - return _content_loaded(d, provider, content) && haskey(d.data[provider][content], locale) +@inline function is_locale_loaded(d::DataContainer, provider::T, content::T, locale::T) :: Bool where {T <: AbstractString} + return is_content_loaded(d, provider, content) && haskey(d.data[provider][content], locale) end @@ -150,29 +150,30 @@ end function _load!(provider::T, content::T, locale::T = "noloc") :: DataFrame where {T <: AbstractString} - @assert(provider_exists(provider), + @assert(is_provider_available(provider), "Provider '$provider' is not available.") - @assert(content_exists(provider, content), + @assert(is_content_available(provider, content), "Content '$content' not available for provider '$provider'") - @assert(locale_exists(provider, content, locale), + @assert(is_locale_available(provider, content, locale), "Locale '$locale' not available for content '$content' of provider '$provider'") - if !_provider_loaded(SESSION_CONTAINER, provider) + if !is_provider_loaded(SESSION_CONTAINER, provider) merge!(SESSION_CONTAINER.data, Dict(provider => Dict())) end - if !_content_loaded(SESSION_CONTAINER, provider, content) + if !is_content_loaded(SESSION_CONTAINER, provider, content) merge!(SESSION_CONTAINER.data[provider], Dict(content => Dict())) end - if !_locale_loaded(SESSION_CONTAINER, provider, content, locale) - data_path = joinpath(ASSETS_ROOT, provider, content, locale * ".csv") - header = joinpath(ASSETS_ROOT, provider, content, "HEADER.txt") |> readlines + if !is_locale_loaded(SESSION_CONTAINER, provider, content, locale) + data_archive_location = joinpath(ASSETS_ROOT, provider, content) + file = joinpath(data_archive_location, locale * ".csv") + header = joinpath(data_archive_location, "HEADER.txt") |> readlines merge!( SESSION_CONTAINER.data[provider][content], - Dict(locale => CSV.read(data_path, DataFrame; header, delim = ',')) + Dict(locale => CSV.read(file, DataFrame; header, delim = ',')) ) end diff --git a/src/data/identity/prefix/ar_AA.csv b/src/data/identity/prefix/ar_AA.csv new file mode 100644 index 0000000..e36f601 --- /dev/null +++ b/src/data/identity/prefix/ar_AA.csv @@ -0,0 +1,9 @@ +F,الآنسة +M,الأستاذ +F,الأستاذة +M,الدكتور +F,الدكتورة +M,السيد +F,السيدة +M,المهندس +F,المهندسة diff --git a/src/data/identity/prefix/ar_AE.csv b/src/data/identity/prefix/ar_AE.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/ar_AE.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/ar_BH.csv b/src/data/identity/prefix/ar_BH.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/ar_BH.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/ar_EG.csv b/src/data/identity/prefix/ar_EG.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/ar_EG.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/ar_JO.csv b/src/data/identity/prefix/ar_JO.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/ar_JO.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/ar_PS.csv b/src/data/identity/prefix/ar_PS.csv new file mode 100644 index 0000000..e36f601 --- /dev/null +++ b/src/data/identity/prefix/ar_PS.csv @@ -0,0 +1,9 @@ +F,الآنسة +M,الأستاذ +F,الأستاذة +M,الدكتور +F,الدكتورة +M,السيد +F,السيدة +M,المهندس +F,المهندسة diff --git a/src/data/identity/prefix/ar_SA.csv b/src/data/identity/prefix/ar_SA.csv new file mode 100644 index 0000000..e36f601 --- /dev/null +++ b/src/data/identity/prefix/ar_SA.csv @@ -0,0 +1,9 @@ +F,الآنسة +M,الأستاذ +F,الأستاذة +M,الدكتور +F,الدكتورة +M,السيد +F,السيدة +M,المهندس +F,المهندسة diff --git a/src/data/identity/prefix/az_AZ.csv b/src/data/identity/prefix/az_AZ.csv new file mode 100644 index 0000000..a66e173 --- /dev/null +++ b/src/data/identity/prefix/az_AZ.csv @@ -0,0 +1,4 @@ +M,Bəy +M,Cənab +M,Müəllim +F,Xanım diff --git a/src/data/identity/prefix/bg_BG.csv b/src/data/identity/prefix/bg_BG.csv new file mode 100644 index 0000000..1fdc27d --- /dev/null +++ b/src/data/identity/prefix/bg_BG.csv @@ -0,0 +1,4 @@ +F,Г-жа +M,Г-н +F,Г-ца +M,Др. diff --git a/src/data/identity/prefix/bn_BD.csv b/src/data/identity/prefix/bn_BD.csv new file mode 100644 index 0000000..33a79de --- /dev/null +++ b/src/data/identity/prefix/bn_BD.csv @@ -0,0 +1,10 @@ +M,ইঞ্জিঃ +M,জনাব +F,জনাবা +M,ডঃ +M,ডাঃ +M,মিঃ +F,মিসঃ +F,মিসেস +M,মৃতঃ +F,মৃতাঃ diff --git a/src/data/identity/prefix/bs_BA.csv b/src/data/identity/prefix/bs_BA.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/bs_BA.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/cs_CZ.csv b/src/data/identity/prefix/cs_CZ.csv new file mode 100644 index 0000000..8820e6c --- /dev/null +++ b/src/data/identity/prefix/cs_CZ.csv @@ -0,0 +1,12 @@ +M,Bc. +M,Ing. +M,Ing. arch. +M,JUDr. +M,MUDr. +M,MVDr. +M,Mgr. +M,PhDr. +M,RNDr. +M,pan +F,paní +F,slečna diff --git a/src/data/identity/prefix/da_DK.csv b/src/data/identity/prefix/da_DK.csv new file mode 100644 index 0000000..29f5701 --- /dev/null +++ b/src/data/identity/prefix/da_DK.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Fru +M,Hr +M,Prof. +M,Univ.Prof. diff --git a/src/data/identity/prefix/de_AT.csv b/src/data/identity/prefix/de_AT.csv new file mode 100644 index 0000000..1cec4a1 --- /dev/null +++ b/src/data/identity/prefix/de_AT.csv @@ -0,0 +1,7 @@ +M,Dipl.-Ing. +M,Dr. +F,Frau +M,Herr +M,Ing. +M,Prof. +M,Univ.Prof. diff --git a/src/data/identity/prefix/de_CH.csv b/src/data/identity/prefix/de_CH.csv new file mode 100644 index 0000000..211435a --- /dev/null +++ b/src/data/identity/prefix/de_CH.csv @@ -0,0 +1,4 @@ +M,Dr. +M,Prof. +F,Dr. +F,Prof. diff --git a/src/data/identity/prefix/de_DE.csv b/src/data/identity/prefix/de_DE.csv new file mode 100644 index 0000000..1cec4a1 --- /dev/null +++ b/src/data/identity/prefix/de_DE.csv @@ -0,0 +1,7 @@ +M,Dipl.-Ing. +M,Dr. +F,Frau +M,Herr +M,Ing. +M,Prof. +M,Univ.Prof. diff --git a/src/data/identity/prefix/dk_DK.csv b/src/data/identity/prefix/dk_DK.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/dk_DK.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/el_CY.csv b/src/data/identity/prefix/el_CY.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/el_CY.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/en_AU.csv b/src/data/identity/prefix/en_AU.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/en_AU.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/en_CA.csv b/src/data/identity/prefix/en_CA.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/en_CA.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/en_GB.csv b/src/data/identity/prefix/en_GB.csv new file mode 100644 index 0000000..e3cecaa --- /dev/null +++ b/src/data/identity/prefix/en_GB.csv @@ -0,0 +1,5 @@ +M,Dr +F,Miss +M,Mr +F,Mrs +F,Ms diff --git a/src/data/identity/prefix/en_IE.csv b/src/data/identity/prefix/en_IE.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/en_IE.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/en_PH.csv b/src/data/identity/prefix/en_PH.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/en_PH.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/en_US.csv b/src/data/identity/prefix/en_US.csv index 61b07f5..a8797b2 100644 --- a/src/data/identity/prefix/en_US.csv +++ b/src/data/identity/prefix/en_US.csv @@ -1,3 +1,5 @@ -M,Mr. M,Dr. +F,Miss +M,Mr. +F,Mrs. F,Ms. diff --git a/src/data/identity/prefix/es_AR.csv b/src/data/identity/prefix/es_AR.csv new file mode 100644 index 0000000..38e0852 --- /dev/null +++ b/src/data/identity/prefix/es_AR.csv @@ -0,0 +1,2 @@ +M,Dr(a). +M,Sr(a). diff --git a/src/data/identity/prefix/es_CA.csv b/src/data/identity/prefix/es_CA.csv new file mode 100644 index 0000000..658fcbf --- /dev/null +++ b/src/data/identity/prefix/es_CA.csv @@ -0,0 +1,2 @@ +M,de +M,del diff --git a/src/data/identity/prefix/es_CL.csv b/src/data/identity/prefix/es_CL.csv new file mode 100644 index 0000000..0c57eb2 --- /dev/null +++ b/src/data/identity/prefix/es_CL.csv @@ -0,0 +1,7 @@ +M,Don +F,Doña +M,Dr. +F,Dra. +M,Sr. +F,Sra. +F,Srta. diff --git a/src/data/identity/prefix/es_CO.csv b/src/data/identity/prefix/es_CO.csv new file mode 100644 index 0000000..d69b867 --- /dev/null +++ b/src/data/identity/prefix/es_CO.csv @@ -0,0 +1,9 @@ +M,D. +M,Don +F,Doña +M,Dr. +F,Dra. +F,Dña. +M,Sr. +F,Sra. +F,Srta. diff --git a/src/data/identity/prefix/es_ES.csv b/src/data/identity/prefix/es_ES.csv new file mode 100644 index 0000000..658fcbf --- /dev/null +++ b/src/data/identity/prefix/es_ES.csv @@ -0,0 +1,2 @@ +M,de +M,del diff --git a/src/data/identity/prefix/es_MX.csv b/src/data/identity/prefix/es_MX.csv new file mode 100644 index 0000000..55e0fc8 --- /dev/null +++ b/src/data/identity/prefix/es_MX.csv @@ -0,0 +1,5 @@ +M,Dr. +M,Ing. +M,Lic. +M,Mtro. +M,Sr(a). diff --git a/src/data/identity/prefix/et_EE.csv b/src/data/identity/prefix/et_EE.csv new file mode 100644 index 0000000..40fbe9f --- /dev/null +++ b/src/data/identity/prefix/et_EE.csv @@ -0,0 +1,7 @@ +M,doktor +M,dr +M,hr +M,härra +F,pr +M,prof +F,proua diff --git a/src/data/identity/prefix/fa_IR.csv b/src/data/identity/prefix/fa_IR.csv new file mode 100644 index 0000000..9803d8b --- /dev/null +++ b/src/data/identity/prefix/fa_IR.csv @@ -0,0 +1,4 @@ +M,جناب آقای +M,جناب آقای دکتر +F,سرکار خانم +F,سرکار خانم دکتر diff --git a/src/data/identity/prefix/fi_FI.csv b/src/data/identity/prefix/fi_FI.csv new file mode 100644 index 0000000..b7e5a08 --- /dev/null +++ b/src/data/identity/prefix/fi_FI.csv @@ -0,0 +1,8 @@ +M,Herra +M,Rouva +M,Tohtori +M,arkkit. +M,hra +M,prof. +M,rva +M,tri diff --git a/src/data/identity/prefix/fil_PH.csv b/src/data/identity/prefix/fil_PH.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/fil_PH.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/fr_BE.csv b/src/data/identity/prefix/fr_BE.csv new file mode 100644 index 0000000..6e7fb8e --- /dev/null +++ b/src/data/identity/prefix/fr_BE.csv @@ -0,0 +1 @@ +M, diff --git a/src/data/identity/prefix/fr_FR.csv b/src/data/identity/prefix/fr_FR.csv new file mode 100644 index 0000000..7a69e4c --- /dev/null +++ b/src/data/identity/prefix/fr_FR.csv @@ -0,0 +1,4 @@ +M,Le +M,de +F,de la +M,du diff --git a/src/data/identity/prefix/ga_IE.csv b/src/data/identity/prefix/ga_IE.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/ga_IE.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/hu_HU.csv b/src/data/identity/prefix/hu_HU.csv new file mode 100644 index 0000000..01be4f3 --- /dev/null +++ b/src/data/identity/prefix/hu_HU.csv @@ -0,0 +1,2 @@ +M,Dr. +M,Prof. Dr. diff --git a/src/data/identity/prefix/id_ID.csv b/src/data/identity/prefix/id_ID.csv new file mode 100644 index 0000000..6ed4808 --- /dev/null +++ b/src/data/identity/prefix/id_ID.csv @@ -0,0 +1,17 @@ +F,Cut +M,Dr. +M,Drs. +M,Dt. +M,H. +F,Hj. +M,Ir. +M,KH. +F,Puti +M,R. +F,R.A. +M,R.M. +M,Sutan +M,T. +M,Tgk. +M,dr. +M,drg. diff --git a/src/data/identity/prefix/it_CH.csv b/src/data/identity/prefix/it_CH.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/it_CH.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/it_IT.csv b/src/data/identity/prefix/it_IT.csv new file mode 100644 index 0000000..ef7636b --- /dev/null +++ b/src/data/identity/prefix/it_IT.csv @@ -0,0 +1,3 @@ +M,Dott. +M,Sig. +F,Sig.ra diff --git a/src/data/identity/prefix/lb_LU.csv b/src/data/identity/prefix/lb_LU.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/lb_LU.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/mt_MT.csv b/src/data/identity/prefix/mt_MT.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/mt_MT.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/ne_NP.csv b/src/data/identity/prefix/ne_NP.csv new file mode 100644 index 0000000..888cc17 --- /dev/null +++ b/src/data/identity/prefix/ne_NP.csv @@ -0,0 +1,4 @@ +M,श्री +F,श्रीमती +M,श्रीमान +F,सुश्री diff --git a/src/data/identity/prefix/no_NO.csv b/src/data/identity/prefix/no_NO.csv new file mode 100644 index 0000000..77105ea --- /dev/null +++ b/src/data/identity/prefix/no_NO.csv @@ -0,0 +1,2 @@ +M,Dr. +M,Prof. diff --git a/src/data/identity/prefix/or_IN.csv b/src/data/identity/prefix/or_IN.csv new file mode 100644 index 0000000..b973e9a --- /dev/null +++ b/src/data/identity/prefix/or_IN.csv @@ -0,0 +1,6 @@ +F,କୁମାରୀ +M,ଶ୍ରୀ +F,ଶ୍ରୀମତୀ +M,ଶ୍ରୀମାନ +M,ଶ୍ରୀଯୁକ୍ତ +F,ସୁଶ୍ରୀ diff --git a/src/data/identity/prefix/pl_PL.csv b/src/data/identity/prefix/pl_PL.csv new file mode 100644 index 0000000..ff7b40e --- /dev/null +++ b/src/data/identity/prefix/pl_PL.csv @@ -0,0 +1,2 @@ +M,pan +F,pani diff --git a/src/data/identity/prefix/pt_BR.csv b/src/data/identity/prefix/pt_BR.csv index b9de8db..793c6cb 100644 --- a/src/data/identity/prefix/pt_BR.csv +++ b/src/data/identity/prefix/pt_BR.csv @@ -1,3 +1,5 @@ +M,Dr. +F,Dra. M,Sr. F,Sra. F,Srta. diff --git a/src/data/identity/prefix/pt_PT.csv b/src/data/identity/prefix/pt_PT.csv new file mode 100644 index 0000000..793c6cb --- /dev/null +++ b/src/data/identity/prefix/pt_PT.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Dra. +M,Sr. +F,Sra. +F,Srta. diff --git a/src/data/identity/prefix/ru_RU.csv b/src/data/identity/prefix/ru_RU.csv new file mode 100644 index 0000000..c50f1ae --- /dev/null +++ b/src/data/identity/prefix/ru_RU.csv @@ -0,0 +1,3 @@ +F,г-жа +M,г-н +M,тов. diff --git a/src/data/identity/prefix/sk_SK.csv b/src/data/identity/prefix/sk_SK.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/sk_SK.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/sq_AL.csv b/src/data/identity/prefix/sq_AL.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/sq_AL.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/th_TH.csv b/src/data/identity/prefix/th_TH.csv new file mode 100644 index 0000000..3ebce9b --- /dev/null +++ b/src/data/identity/prefix/th_TH.csv @@ -0,0 +1,53 @@ +M,จ.ต. +M,จ.ท. +M,จ.ส.ต. +M,จ.ส.ท. +M,จ.ส.อ. +M,จ.อ. +M,ด.ช. +F,ด.ญ. +M,ด.ต. +M,น.ต. +M,น.ท. +F,น.ส. +M,น.อ. +F,นาง +F,นางสาว +M,นาย +M,พ.จ.ต. +M,พ.จ.ท. +M,พ.จ.อ. +M,พ.ต. +M,พ.ต.ต. +M,พ.ต.ท. +M,พ.ต.อ. +M,พ.ท. +M,พ.อ. +M,พ.อ.ต. +M,พ.อ.ท. +M,พ.อ.อ. +F,พล.ต. +F,พล.ต.ท. +M,พล.ต.อ. +M,พล.ท. +M,พล.ร.ท. +M,พล.ร.อ. +F,พล.อ. +M,พล.อ.ท. +M,ม.ร.ว. +M,ม.ล. +M,ร.ต. +M,ร.ต.ต. +M,ร.ต.ท. +M,ร.ต.อ. +M,ร.ท. +M,ร.อ. +M,ส.ต. +M,ส.ต.ต. +M,ส.ต.ท. +M,ส.ต.อ. +M,ส.ท. +M,ส.อ. +M,สามเณร +F,หม่อมราชวงศ์ +F,เด็กหญิง diff --git a/src/data/identity/prefix/tl_PH.csv b/src/data/identity/prefix/tl_PH.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/tl_PH.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/data/identity/prefix/tr_TR.csv b/src/data/identity/prefix/tr_TR.csv new file mode 100644 index 0000000..1ceebb7 --- /dev/null +++ b/src/data/identity/prefix/tr_TR.csv @@ -0,0 +1,12 @@ +M,Arş. Gör. +M,Av. +M,Bay +F,Bayan +M,Doç. +M,Dr. +M,Okt. +M,Prof. +M,Uz. +M,Yrd. Doç. +M,Çev. +M,Öğr. diff --git a/src/data/identity/prefix/tw_GH.csv b/src/data/identity/prefix/tw_GH.csv new file mode 100644 index 0000000..8e2b58d --- /dev/null +++ b/src/data/identity/prefix/tw_GH.csv @@ -0,0 +1,13 @@ +M,Agya +F,Awura +M,Dr. +F,Maame +F,Mama +F,Miss +M,Mr. +F,Mrs. +F,Ms. +M,Osofo +F,Osofo Maame +M,Owura +F,Sista diff --git a/src/data/identity/prefix/uk_UA.csv b/src/data/identity/prefix/uk_UA.csv new file mode 100644 index 0000000..f8d942c --- /dev/null +++ b/src/data/identity/prefix/uk_UA.csv @@ -0,0 +1,2 @@ +M,пан +F,пані diff --git a/src/data/identity/prefix/vi_VN.csv b/src/data/identity/prefix/vi_VN.csv new file mode 100644 index 0000000..a8797b2 --- /dev/null +++ b/src/data/identity/prefix/vi_VN.csv @@ -0,0 +1,5 @@ +M,Dr. +F,Miss +M,Mr. +F,Mrs. +F,Ms. diff --git a/src/providers/miscellaneous.jl b/src/providers/miscellaneous.jl index d610064..b505da4 100644 --- a/src/providers/miscellaneous.jl +++ b/src/providers/miscellaneous.jl @@ -1,5 +1,7 @@ """ + locale_code(n::Integer = 1; kwargs...) +Return `n` random available locale codes (*e.g.* `"en_US"`). """ function locale_code(n::Integer = 1; kwargs...) locale_codes = get_all_locales() diff --git a/test/data_integrity/test_identity.jl b/test/data_integrity/test_identity.jl index 53b210e..bfa5cda 100644 --- a/test/data_integrity/test_identity.jl +++ b/test/data_integrity/test_identity.jl @@ -1,37 +1,39 @@ @testset "Identity" begin for locale in ALL_LOCALES - locale_exists("identity", "highschool", locale) && @testset "[$locale] highschool" begin - df = Impostor._load!("identity", "highschool", locale) - @test allunique(df, :highschool) - end + @testset "[$locale]" begin + is_locale_available("identity", "highschool", locale) && @testset "highschool" begin + df = Impostor._load!("identity", "highschool", locale) + @test allunique(df, :highschool) + end - locale_exists("identity", "surname", locale) && @testset "[$locale] surname" begin - df = Impostor._load!("identity", "surname", locale) - @test titlecase.(df[:, :surname]) |> allunique - end + is_locale_available("identity", "surname", locale) && @testset "surname" begin + df = Impostor._load!("identity", "surname", locale) + @test titlecase.(df[:, :surname]) |> allunique + end - locale_exists("identity", "nationality", locale) && @testset "[$locale] nationality" begin - df = Impostor._load!("identity", "nationality", locale) - country_codes = Impostor._load!("localization", "country", locale)[:, :country_code] - @test Set(df[:, :sex]) == Set(SEXES[:options]) - @test all([code in country_codes for code in df[:, :country_code]]) - end + is_locale_available("identity", "nationality", locale) && @testset "nationality" begin + df = Impostor._load!("identity", "nationality", locale) + country_codes = Impostor._load!("localization", "country", locale)[:, :country_code] + @test Set(df[:, :sex]) == Set(SEXES[:options]) + @test all([code in country_codes for code in df[:, :country_code]]) + end - # functions using SEX as data restriction - for func in [prefix, firstname] - locale_exists("identity", string(func), locale) && @testset "[$locale] $func" begin - df = Impostor._load!("identity", string(func), locale) - @test allunique(df, Symbol(func)) - @test sort(unique(df[:, :sex])) == sort(SEXES[:options]) + # functions using SEX as data restriction + for func in [prefix, firstname] + is_locale_available("identity", string(func), locale) && @testset "$func" begin + df = Impostor._load!("identity", string(func), locale) + @test allunique(df, Symbol(func)) + @test sort(unique(df[:, :sex])) == sort(SEXES[:options]) + end end - end - # functions using KNOWLEDGE_FIELD as data restriction - for func in [university, occupation] - locale_exists("identity", string(func), locale) && @testset "[$locale] $func" begin - df = Impostor._load!("identity", string(func), locale) - @test allunique(df, Symbol(func)) - @test sort(unique(df[:, :knowledge_field])) == sort(KNOWLEDGE_FIELDS[:options]) + # functions using KNOWLEDGE_FIELD as data restriction + for func in [university, occupation] + is_locale_available("identity", string(func), locale) && @testset "$func" begin + df = Impostor._load!("identity", string(func), locale) + @test allunique(df, Symbol(func)) + @test sort(unique(df[:, :knowledge_field])) == sort(KNOWLEDGE_FIELDS[:options]) + end end end end diff --git a/test/data_integrity/test_localization.jl b/test/data_integrity/test_localization.jl index 04f9e91..db6c90b 100644 --- a/test/data_integrity/test_localization.jl +++ b/test/data_integrity/test_localization.jl @@ -1,60 +1,62 @@ @testset "Localization" begin for locale in ALL_LOCALES - locale_exists("localization", "address_complement", locale) && @testset "[$locale] address_complement" begin - df = Impostor._load!("localization", "address_complement", locale) - @test uppercase.(df[:, :address_complement]) |> allunique - end + @testset "[$locale]" begin + is_locale_available("localization", "address_complement", locale) && @testset "address_complement" begin + df = Impostor._load!("localization", "address_complement", locale) + @test uppercase.(df[:, :address_complement]) |> allunique + end - locale_exists("localization", "address_format", locale) && @testset "[$locale] address_format" begin - df = Impostor._load!("localization", "address_format", locale) - @test uppercase.(df[:, :address_format]) |> allunique - end + is_locale_available("localization", "address_format", locale) && @testset "address_format" begin + df = Impostor._load!("localization", "address_format", locale) + @test uppercase.(df[:, :address_format]) |> allunique + end - locale_exists("localization", "locale", locale) && @testset "[$locale] locale" begin - df = Impostor._load!("localization", "locale", locale) - @test allunique(df, :locale) - @test uppercase.(df[:, :country_code]) |> allunique - end + is_locale_available("localization", "locale", locale) && @testset "locale" begin + df = Impostor._load!("localization", "locale", locale) + @test allunique(df, :locale) + @test uppercase.(df[:, :country_code]) |> allunique + end - locale_exists("localization", "country", locale) && @testset "[$locale] country" begin - df = Impostor._load!("localization", "country", locale) - @test allunique(df, :country) - @test allunique(df, :country_official_name) - @test (df[:, :locale] .== locale) |> all - end + is_locale_available("localization", "country", locale) && @testset "country" begin + df = Impostor._load!("localization", "country", locale) + @test allunique(df, :country) + @test allunique(df, :country_official_name) + @test (df[:, :locale] .== locale) |> all + end - locale_exists("localization", "state", locale) && @testset "[$locale] state" begin - df = Impostor._load!("localization", "state", locale) - @test allunique(df, :state) - @test uppercase.(df[:, :state_code]) |> allunique - end + is_locale_available("localization", "state", locale) && @testset "state" begin + df = Impostor._load!("localization", "state", locale) + @test allunique(df, :state) + @test uppercase.(df[:, :state_code]) |> allunique + end - locale_exists("localization", "city", locale) && @testset "[$locale] city" begin - df = Impostor._load!("localization", "city", locale) - @test allunique(df, [:state_code, :city]) - end + is_locale_available("localization", "city", locale) && @testset "city" begin + df = Impostor._load!("localization", "city", locale) + @test allunique(df, [:state_code, :city]) + end - locale_exists("localization", "district", locale) && @testset "[$locale] district" begin - df = Impostor._load!("localization", "district", locale) - @test allunique(df, :district) - end + is_locale_available("localization", "district", locale) && @testset "district" begin + df = Impostor._load!("localization", "district", locale) + @test allunique(df, :district) + end - locale_exists("localization", "street_prefix", locale) && @testset "[$locale] street_prefix" begin - df = Impostor._load!("localization", "street_prefix", locale) - @test allunique(df, :street_prefix) - end + is_locale_available("localization", "street_prefix", locale) && @testset "street_prefix" begin + df = Impostor._load!("localization", "street_prefix", locale) + @test allunique(df, :street_prefix) + end - locale_exists("localization", "street_suffix", locale) && @testset "[$locale] street_suffix" begin - df = Impostor._load!("localization", "street_suffix", locale) - @test allunique(df, :street_suffix) - end + is_locale_available("localization", "street_suffix", locale) && @testset "street_suffix" begin + df = Impostor._load!("localization", "street_suffix", locale) + @test allunique(df, :street_suffix) + end - locale_exists("localization", "street_format", locale) && @testset "[$locale] street_format" begin - df = Impostor._load!("localization", "street_format", locale) - @test allunique(df, :street_format) - for row in eachrow(df) - for token in split(row[:street_format], " ") - @test Symbol(token) in names(Impostor) + is_locale_available("localization", "street_format", locale) && @testset "street_format" begin + df = Impostor._load!("localization", "street_format", locale) + @test allunique(df, :street_format) + for row in eachrow(df) + for token in split(row[:street_format], " ") + @test Symbol(token) in names(Impostor) + end end end end diff --git a/test/test_data_interface.jl b/test/test_data_interface.jl index 857de74..8f22221 100644 --- a/test/test_data_interface.jl +++ b/test/test_data_interface.jl @@ -38,12 +38,12 @@ end @testset "Data Loading Auxiliary Functions" begin - @test provider_exists("identity") - @test !provider_exists("indentity") # typo in 'identity' on purpose + @test is_provider_available("identity") + @test !is_provider_available("indentity") # typo in 'identity' on purpose - @test content_exists("identity", "firstname") - @test !content_exists("identity", "fisrtname") # typo in 'firstname' on purpose + @test is_content_available("identity", "firstname") + @test !is_content_available("identity", "fisrtname") # typo in 'firstname' on purpose - @test locale_exists("identity", "firstname", "en_US") - @test !locale_exists("identity", "fisrtname", "en_US") # typo in 'firstnames' on purpose + @test is_locale_available("identity", "firstname", "en_US") + @test !is_locale_available("identity", "firstname", "xx_XX") end diff --git a/test/utils.jl b/test/utils.jl index 7f14669..f2447c0 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -11,20 +11,3 @@ end function _test_load(provider::String, content::String, locale::Vector{String}) return Dict(loc => _test_load(provider, content, loc) for loc in locale) end - -""" - _get_all_locales(; root::AbstractString) :: Vector{String} - -Retrieve a list of all unique locales (inclusing the "noloc" locale) available in all providers -""" -function _get_all_locales(; root::AbstractString) :: Vector{String} - to_skip = ["HEADER"] - unique_locales = Set{String}() - for (_, _, files) in walkdir(root) - for filename in files - locale = first(split(filename, '.')) - !(locale in to_skip) && push!(unique_locales, locale) - end - end - return collect(unique_locales) - end