def test_protocol() -> None: template: Node[PersonProtocol] = join([ tag(TagType.EMPHASIS, name()), str_(': '), tag(TagType.STRONG, birthday("%b %d, %Y"))]) person1 = Person( name='John', birthday=datetime.date(year=1998, month=3, day=7)) person2 = PersonWithGender( name='Mary', birthday=datetime.date(year=1997, month=6, day=22), female=True) text1 = template(person1) text2 = template(person2) assert text1 == Text([ Tag(TagType.EMPHASIS, _s('John')), _s(': '), Tag(TagType.STRONG, _s('Mar 07, 1998'))]) assert text2 == Text([ Tag(TagType.EMPHASIS, _s('Mary')), _s(': '), Tag(TagType.STRONG, _s('Jun 22, 1997'))])
def test_capfirst(): template = capfirst(join([str_(''), str_data(), str_(' world')])) assert template('hello') == Text([_s(''), _t('Hello'), _s(' world')])
def test_template() -> None: template: Node[str] = join([str_data(), str_(' world')]) assert template('hello') == Text([_t('hello'), _s(' world')])
def test_upper(): template = upper(join([str_(''), str_data(), str_(' WORLD')])) assert template('heLLo') == Text([_s(''), _t('HELLO'), _s(' WORLD')])
def test_lower(): template = lower(join([str_(''), str_data(), str_(' WORLD')])) assert template('heLLo') == Text([_s(''), _t('hello'), _s(' world')])
def test_capitalize(): template = capitalize(join([str_(''), str_data(), str_(' WORLD')])) assert template('heLLo') == Text([_s(''), _t('Hello'), _s(' world')])