Skip to content

Commit

Permalink
Update utils::get_today_string format
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r committed Nov 9, 2023
1 parent d49b2e5 commit 311628f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions api/scpca_portal/test/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from datetime import date
from unittest.mock import patch

from django.test import TestCase

from scpca_portal import utils
Expand Down Expand Up @@ -37,3 +40,10 @@ def test_join_multiple_items(self):
def test_join_single_item(self):
items = ("single item",)
self.assertEqual(utils.join_workflow_versions(items), items[0])


class TestGetToday(TestCase):
@patch("scpca_portal.utils.datetime")
def test_format(self, mock_date):
mock_date.today.return_value = date(2022, 10, 8)
self.assertEqual(utils.get_today_string(), "2022-10-08")
2 changes: 1 addition & 1 deletion api/scpca_portal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ def join_workflow_versions(workflow_versions):
return ", ".join(sorted(set(workflow_versions)))


def get_today_string(format: str = "%Y-%M-%d"):
def get_today_string(format: str = "%Y-%m-%d"):
"""Returns today's date formatted. Defaults to ISO 8601."""
return datetime.today().strftime(format)

0 comments on commit 311628f

Please sign in to comment.