Skip to content

Commit

Permalink
Add color provider for id_ID (#1737)
Browse files Browse the repository at this point in the history
Signed-off-by: rosdyana <rosdyana.kusuma@gmail.com>
  • Loading branch information
rosdyana committed Nov 7, 2022
1 parent f8ad101 commit 1d2ef0b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
60 changes: 60 additions & 0 deletions faker/providers/color/id_ID/__init__.py
@@ -0,0 +1,60 @@
from collections import OrderedDict

from .. import Provider as ColorProvider

localized = True


class Provider(ColorProvider):
"""Implement color provider for ``id_ID`` locale.
Sources:
- https://id.wikipedia.org/wiki/Daftar_warna
"""

all_colors = OrderedDict(
(
("Abu-abu", "#808080"),
("Biru", "#0000FF"),
("Biru dongker", "#00008B"),
("Biru laut", "#0000CD"),
("Biru muda", "#ADD8E6"),
("Coklat", "#A52A2A"),
("Coklat tua", "#8B4513"),
("Emas", "#FFD700"),
("Hijau", "#008000"),
("Hijau muda", "#90EE90"),
("Hijau tua", "#006400"),
("Hitam", "#000000"),
("Jingga", "#FFA500"),
("Kuning", "#FFFF00"),
("Koral", "#FF7F50"),
("Magenta", "#FF00FF"),
("Merah", "#FF0000"),
("Merah marun", "#800000"),
("Merah jambu", "#FFC0CB"),
("Merah bata", "#B22222"),
("Perak", "#C0C0C0"),
("Nila", "#000080"),
("Putih", "#FFFFFF"),
("Ungu", "#800080"),
("Ungu tua", "#4B0082"),
("Zaitun", "#808000"),
)
)

safe_colors = (
"putih",
"hitam",
"merah",
"hijau",
"kuning",
"biru",
"ungu",
"abu-abu",
"coklat",
"perak",
"emas",
"pink",
"oranye",
)
17 changes: 17 additions & 0 deletions tests/providers/test_color.py
Expand Up @@ -14,6 +14,7 @@
from faker.providers.color.fa_IR import Provider as FaIrColorProvider
from faker.providers.color.he_IL import Provider as HeILColorProvider
from faker.providers.color.hy_AM import Provider as HyAmColorProvider
from faker.providers.color.id_ID import Provider as IdIdColorProvider
from faker.providers.color.sk_SK import Provider as SkSkColorProvider


Expand Down Expand Up @@ -352,3 +353,19 @@ def test_safe_color_name(self, faker, num_samples):
safe_color_name = faker.safe_color_name()
assert isinstance(safe_color_name, str)
assert safe_color_name in HeILColorProvider.safe_colors


class TestIdId:
"""Test id_ID color provider methods"""

def test_color_name(self, faker, num_samples):
for _ in range(num_samples):
color_name = faker.color_name()
assert isinstance(color_name, str)
assert color_name in IdIdColorProvider.all_colors.keys()

def test_safe_color_name(self, faker, num_samples):
for _ in range(num_samples):
safe_color_name = faker.safe_color_name()
assert isinstance(safe_color_name, str)
assert safe_color_name in IdIdColorProvider.safe_colors

0 comments on commit 1d2ef0b

Please sign in to comment.