Skip to content

Commit

Permalink
test(locale): DATE_FORMAT results in expected str
Browse files Browse the repository at this point in the history
adding a few init files here to get test discovery to work with the
new locale directories
  • Loading branch information
thekaveman committed Apr 29, 2024
1 parent 77e9e65 commit 9cdacdc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Empty file added tests/__init__.py
Empty file.
Empty file added tests/pytest/__init__.py
Empty file.
Empty file added tests/pytest/locale/__init__.py
Empty file.
36 changes: 36 additions & 0 deletions tests/pytest/locale/test_formats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from datetime import datetime

import pytest

from django.utils.formats import date_format

from benefits.locale.en.formats import DATE_FORMAT as DATE_FORMAT_EN
from benefits.locale.es.formats import DATE_FORMAT as DATE_FORMAT_ES


@pytest.fixture
def date_december():
return datetime(2024, 12, 1)


@pytest.fixture
def date_march():
return datetime(2024, 3, 1)


def test_en_DATE_FORMAT_december(date_december):
assert date_format(date_december, DATE_FORMAT_EN) == "December 1, 2024"


def test_en_DATE_FORMAT_march(date_march):
assert date_format(date_march, DATE_FORMAT_EN) == "March 1, 2024"


def test_es_DATE_FORMAT_december(settings, date_december):
settings.LANGUAGE_CODE = "es"
assert date_format(date_december, DATE_FORMAT_ES) == "1 de diciembre de 2024"


def test_es_DATE_FORMAT_march(settings, date_march):
settings.LANGUAGE_CODE = "es"
assert date_format(date_march, DATE_FORMAT_ES) == "1 de marzo de 2024"

0 comments on commit 9cdacdc

Please sign in to comment.