test: dynamic fiscal year creation in tests (#28667)
This commit is contained in:
parent
445966ab80
commit
fdffa037b5
@ -5,10 +5,10 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.utils import now_datetime
|
||||||
|
|
||||||
from erpnext.accounts.doctype.fiscal_year.fiscal_year import FiscalYearIncorrectDate
|
from erpnext.accounts.doctype.fiscal_year.fiscal_year import FiscalYearIncorrectDate
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Fiscal Year')
|
|
||||||
test_ignore = ["Company"]
|
test_ignore = ["Company"]
|
||||||
|
|
||||||
class TestFiscalYear(unittest.TestCase):
|
class TestFiscalYear(unittest.TestCase):
|
||||||
@ -25,3 +25,29 @@ class TestFiscalYear(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
self.assertRaises(FiscalYearIncorrectDate, fy.insert)
|
self.assertRaises(FiscalYearIncorrectDate, fy.insert)
|
||||||
|
|
||||||
|
|
||||||
|
def test_record_generator():
|
||||||
|
test_records = [
|
||||||
|
{
|
||||||
|
"doctype": "Fiscal Year",
|
||||||
|
"year": "_Test Short Fiscal Year 2011",
|
||||||
|
"is_short_year": 1,
|
||||||
|
"year_end_date": "2011-04-01",
|
||||||
|
"year_start_date": "2011-12-31"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
start = 2012
|
||||||
|
end = now_datetime().year + 5
|
||||||
|
for year in range(start, end):
|
||||||
|
test_records.append({
|
||||||
|
"doctype": "Fiscal Year",
|
||||||
|
"year": f"_Test Fiscal Year {year}",
|
||||||
|
"year_start_date": f"{year}-01-01",
|
||||||
|
"year_end_date": f"{year}-12-31"
|
||||||
|
})
|
||||||
|
|
||||||
|
return test_records
|
||||||
|
|
||||||
|
test_records = test_record_generator()
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Short Fiscal Year 2011",
|
|
||||||
"is_short_year": 1,
|
|
||||||
"year_end_date": "2011-04-01",
|
|
||||||
"year_start_date": "2011-12-31"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2012",
|
|
||||||
"year_end_date": "2012-12-31",
|
|
||||||
"year_start_date": "2012-01-01"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2013",
|
|
||||||
"year_end_date": "2013-12-31",
|
|
||||||
"year_start_date": "2013-01-01"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2014",
|
|
||||||
"year_end_date": "2014-12-31",
|
|
||||||
"year_start_date": "2014-01-01"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2015",
|
|
||||||
"year_end_date": "2015-12-31",
|
|
||||||
"year_start_date": "2015-01-01"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2016",
|
|
||||||
"year_end_date": "2016-12-31",
|
|
||||||
"year_start_date": "2016-01-01"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2017",
|
|
||||||
"year_end_date": "2017-12-31",
|
|
||||||
"year_start_date": "2017-01-01"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2018",
|
|
||||||
"year_end_date": "2018-12-31",
|
|
||||||
"year_start_date": "2018-01-01"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2019",
|
|
||||||
"year_end_date": "2019-12-31",
|
|
||||||
"year_start_date": "2019-01-01"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2020",
|
|
||||||
"year_end_date": "2020-12-31",
|
|
||||||
"year_start_date": "2020-01-01"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2021",
|
|
||||||
"year_end_date": "2021-12-31",
|
|
||||||
"year_start_date": "2021-01-01"
|
|
||||||
}
|
|
||||||
]
|
|
Loading…
x
Reference in New Issue
Block a user