Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add color ID #1737

Merged
merged 2 commits into from Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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