brotherton-erpnext/erpnext/stock/report/stock_analytics/test_stock_analytics.py
Chillar Anand 915b34391c
chore: Clean up imports (#27302)
* chore: Added isort to pre-commit config

* chore: Sort imports with isort

* chore: Clean up imports with pycln

* chore: Sort imports with isort

* chore: Fix import issues

* chore: Clean up sider issues

* chore: Remove import errors from flake8 ignore list

* chore: Clean up lint issues
2021-09-02 16:44:59 +05:30

36 lines
1006 B
Python

import datetime
import unittest
from frappe import _dict
from erpnext.accounts.utils import get_fiscal_year
from erpnext.stock.report.stock_analytics.stock_analytics import get_period_date_ranges
class TestStockAnalyticsReport(unittest.TestCase):
def test_get_period_date_ranges(self):
filters = _dict(range="Monthly", from_date="2020-12-28", to_date="2021-02-06")
ranges = get_period_date_ranges(filters)
expected_ranges = [
[datetime.date(2020, 12, 1), datetime.date(2020, 12, 31)],
[datetime.date(2021, 1, 1), datetime.date(2021, 1, 31)],
[datetime.date(2021, 2, 1), datetime.date(2021, 2, 6)],
]
self.assertEqual(ranges, expected_ranges)
def test_get_period_date_ranges_yearly(self):
filters = _dict(range="Yearly", from_date="2021-01-28", to_date="2021-02-06")
ranges = get_period_date_ranges(filters)
first_date = get_fiscal_year("2021-01-28")[1]
expected_ranges = [
[first_date, datetime.date(2021, 2, 6)],
]
self.assertEqual(ranges, expected_ranges)