From 9cdacdcf8e9768ec6e8e92895c57417195ad6be4 Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Mon, 29 Apr 2024 19:37:40 +0000 Subject: [PATCH] test(locale): DATE_FORMAT results in expected str adding a few init files here to get test discovery to work with the new locale directories --- tests/__init__.py | 0 tests/pytest/__init__.py | 0 tests/pytest/locale/__init__.py | 0 tests/pytest/locale/test_formats.py | 36 +++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/pytest/__init__.py create mode 100644 tests/pytest/locale/__init__.py create mode 100644 tests/pytest/locale/test_formats.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/pytest/__init__.py b/tests/pytest/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/pytest/locale/__init__.py b/tests/pytest/locale/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/pytest/locale/test_formats.py b/tests/pytest/locale/test_formats.py new file mode 100644 index 000000000..77499a42d --- /dev/null +++ b/tests/pytest/locale/test_formats.py @@ -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"