Newer
Older
NewLang / tests / test_i18n.py
# SPDX-License-Identifier: LGPL-2.1-only
# Copyright 2022 Jookia <contact@jookia.org>

# The i18n module provides the following:
# - A Message data structure
#
# The Message data structure contains:
# - A string identifier
# - A dictionary of string keys to arbitrary values

from hypothesis.strategies import (
    binary,
    composite,
    lists,
    text,
)

from newlang.i18n import Message
from tests.templates import template_test_structure


# Draws a message identifier
@composite
def draw_message_identifier(draw):
    return draw(text())


# Draws values for a message
@composite
def draw_message_values(draw):
    return draw(lists(binary()))


# Draws a random message
@composite
def draw_message_random(draw):
    id = draw(draw_message_identifier())
    values = draw(draw_message_values())
    return Message(id, values)


# Test message structure
@template_test_structure(
    Message,
    draw_message_random(),
    id=draw_message_identifier(),
    values=draw_message_values(),
)
def test_i18n_message_structure():
    pass