"""Unit tests for the date related tasks.""" from unittest.mock import MagicMock from feed_ingestion.tasks import date_tasks def test_get_first_day_of_month(): """Test get_first_day_of_month.""" expected_response = {'date': '2018-05-01'} # with the first day assert date_tasks.get_first_day_of_month( MagicMock(), '2018-05-01') == expected_response # with day in the middle of the month assert date_tasks.get_first_day_of_month( MagicMock(), '2018-05-23') == expected_response # with last day of the month assert date_tasks.get_first_day_of_month( MagicMock(), '2018-05-31') == expected_response def test_get_first_day_of_week(): """Test get_first_day_of_week.""" expected_response = {'date': '2020-02-24'} # with the first day assert date_tasks.get_first_day_of_week( MagicMock(), '2020-02-25') == expected_response # with day in the middle of the month assert date_tasks.get_first_day_of_week( MagicMock(), '2020-02-28') == expected_response # with last day of the month assert date_tasks.get_first_day_of_week( MagicMock(), '2020-03-01') == expected_response