fix: add dashboard test for doctype
This commit is contained in:
parent
7d53df4353
commit
4ce89cb8b0
3 changed files with 6 additions and 6 deletions
|
|
@ -12,8 +12,8 @@ def cache_source(function):
|
|||
no_cache = kwargs.get("no_cache")
|
||||
if no_cache:
|
||||
return function(chart, no_cache)
|
||||
chart_name = frappe.parse_json(chart)['name']
|
||||
cache_key = 'chart-data:{}'.format(chart_name)
|
||||
chart_name = frappe.parse_json(chart).name
|
||||
cache_key = "chart-data:{}".format(chart_name)
|
||||
if int(kwargs.get("refresh") or 0):
|
||||
results = generate_and_cache_results(chart, chart_name, function, cache_key)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from frappe.model.document import Document
|
|||
@cache_source
|
||||
def get(chart, no_cache=None, from_date=None, to_date=None, refresh = None):
|
||||
|
||||
chart = frappe._dict(frappe.parse_json(chart))
|
||||
chart = frappe.parse_json(chart)
|
||||
timespan = chart.timespan
|
||||
timegrain = chart.time_interval
|
||||
filters = frappe.parse_json(chart.filters_json)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class TestDashboardChart(unittest.TestCase):
|
|||
if frappe.db.exists('Dashboard Chart', 'Test Dashboard Chart'):
|
||||
frappe.delete_doc('Dashboard Chart', 'Test Dashboard Chart')
|
||||
|
||||
chart = dict(
|
||||
chart = frappe.get_doc(dict(
|
||||
doctype = 'Dashboard Chart',
|
||||
chart_name = 'Test Dashboard Chart',
|
||||
name = 'Test Dashboard Chart',
|
||||
|
|
@ -51,11 +51,11 @@ class TestDashboardChart(unittest.TestCase):
|
|||
time_interval = 'Monthly',
|
||||
filters_json = '{}',
|
||||
timeseries = 1
|
||||
)
|
||||
)).insert()
|
||||
|
||||
cur_date = datetime.now() - relativedelta(years=1)
|
||||
|
||||
result = get(chart = chart, refresh = 1)
|
||||
result = get(chart = chart)
|
||||
for idx in range(13):
|
||||
month = datetime(int(cur_date.year), int(cur_date.strftime('%m')), int(calendar.monthrange(cur_date.year, cur_date.month)[1]))
|
||||
month = formatdate(month.strftime('%Y-%m-%d'))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue