Skip to content

Commit

Permalink
Merge pull request #9 from lfenzo/test/change-order-of-testsets
Browse files Browse the repository at this point in the history
test: change order of testsets
  • Loading branch information
lfenzo authored Jan 21, 2024
2 parents d16009b + 1035d4b commit bd5a2b7
Show file tree
Hide file tree
Showing 66 changed files with 482 additions and 128 deletions.
6 changes: 3 additions & 3 deletions docs/src/developer_guide/data_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
6 changes: 3 additions & 3 deletions src/Impostor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 26 additions & 25 deletions src/core/data_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,34 @@ 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`.
# Parameters
- `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`.
Expand All @@ -83,46 +83,46 @@ 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



"""
_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


Expand Down Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions src/data/identity/prefix/ar_AA.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
F,الآنسة
M,الأستاذ
F,الأستاذة
M,الدكتور
F,الدكتورة
M,السيد
F,السيدة
M,المهندس
F,المهندسة
5 changes: 5 additions & 0 deletions src/data/identity/prefix/ar_AE.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
5 changes: 5 additions & 0 deletions src/data/identity/prefix/ar_BH.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
5 changes: 5 additions & 0 deletions src/data/identity/prefix/ar_EG.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
5 changes: 5 additions & 0 deletions src/data/identity/prefix/ar_JO.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
9 changes: 9 additions & 0 deletions src/data/identity/prefix/ar_PS.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
F,الآنسة
M,الأستاذ
F,الأستاذة
M,الدكتور
F,الدكتورة
M,السيد
F,السيدة
M,المهندس
F,المهندسة
9 changes: 9 additions & 0 deletions src/data/identity/prefix/ar_SA.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
F,الآنسة
M,الأستاذ
F,الأستاذة
M,الدكتور
F,الدكتورة
M,السيد
F,السيدة
M,المهندس
F,المهندسة
4 changes: 4 additions & 0 deletions src/data/identity/prefix/az_AZ.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
M,Bəy
M,Cənab
M,Müəllim
F,Xanım
4 changes: 4 additions & 0 deletions src/data/identity/prefix/bg_BG.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
F,Г-жа
M,Г-н
F,Г-ца
M,Др.
10 changes: 10 additions & 0 deletions src/data/identity/prefix/bn_BD.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
M,ইঞ্জিঃ
M,জনাব
F,জনাবা
M,ডঃ
M,ডাঃ
M,মিঃ
F,মিসঃ
F,মিসেস
M,মৃতঃ
F,মৃতাঃ
5 changes: 5 additions & 0 deletions src/data/identity/prefix/bs_BA.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
12 changes: 12 additions & 0 deletions src/data/identity/prefix/cs_CZ.csv
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions src/data/identity/prefix/da_DK.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Fru
M,Hr
M,Prof.
M,Univ.Prof.
7 changes: 7 additions & 0 deletions src/data/identity/prefix/de_AT.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
M,Dipl.-Ing.
M,Dr.
F,Frau
M,Herr
M,Ing.
M,Prof.
M,Univ.Prof.
4 changes: 4 additions & 0 deletions src/data/identity/prefix/de_CH.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
M,Dr.
M,Prof.
F,Dr.
F,Prof.
7 changes: 7 additions & 0 deletions src/data/identity/prefix/de_DE.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
M,Dipl.-Ing.
M,Dr.
F,Frau
M,Herr
M,Ing.
M,Prof.
M,Univ.Prof.
5 changes: 5 additions & 0 deletions src/data/identity/prefix/dk_DK.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
5 changes: 5 additions & 0 deletions src/data/identity/prefix/el_CY.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
5 changes: 5 additions & 0 deletions src/data/identity/prefix/en_AU.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
5 changes: 5 additions & 0 deletions src/data/identity/prefix/en_CA.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
5 changes: 5 additions & 0 deletions src/data/identity/prefix/en_GB.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr
F,Miss
M,Mr
F,Mrs
F,Ms
5 changes: 5 additions & 0 deletions src/data/identity/prefix/en_IE.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
5 changes: 5 additions & 0 deletions src/data/identity/prefix/en_PH.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
4 changes: 3 additions & 1 deletion src/data/identity/prefix/en_US.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
M,Mr.
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
2 changes: 2 additions & 0 deletions src/data/identity/prefix/es_AR.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
M,Dr(a).
M,Sr(a).
2 changes: 2 additions & 0 deletions src/data/identity/prefix/es_CA.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
M,de
M,del
7 changes: 7 additions & 0 deletions src/data/identity/prefix/es_CL.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
M,Don
F,Doña
M,Dr.
F,Dra.
M,Sr.
F,Sra.
F,Srta.
9 changes: 9 additions & 0 deletions src/data/identity/prefix/es_CO.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
M,D.
M,Don
F,Doña
M,Dr.
F,Dra.
F,Dña.
M,Sr.
F,Sra.
F,Srta.
2 changes: 2 additions & 0 deletions src/data/identity/prefix/es_ES.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
M,de
M,del
5 changes: 5 additions & 0 deletions src/data/identity/prefix/es_MX.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
M,Ing.
M,Lic.
M,Mtro.
M,Sr(a).
7 changes: 7 additions & 0 deletions src/data/identity/prefix/et_EE.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
M,doktor
M,dr
M,hr
M,härra
F,pr
M,prof
F,proua
4 changes: 4 additions & 0 deletions src/data/identity/prefix/fa_IR.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
M,جناب آقای
M,جناب آقای دکتر
F,سرکار خانم
F,سرکار خانم دکتر
8 changes: 8 additions & 0 deletions src/data/identity/prefix/fi_FI.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
M,Herra
M,Rouva
M,Tohtori
M,arkkit.
M,hra
M,prof.
M,rva
M,tri
5 changes: 5 additions & 0 deletions src/data/identity/prefix/fil_PH.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
M,Dr.
F,Miss
M,Mr.
F,Mrs.
F,Ms.
1 change: 1 addition & 0 deletions src/data/identity/prefix/fr_BE.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M,
4 changes: 4 additions & 0 deletions src/data/identity/prefix/fr_FR.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
M,Le
M,de
F,de la
M,du
Loading

0 comments on commit bd5a2b7

Please sign in to comment.