def test_get_entity_by_path_dataset(self): entity = get_entity_by_path('datasets/dummy.py', 'Dataset', {}) self.assertEqual(str(type(entity)), "<class 'datasets.dummy.Dataset'>") entity = get_entity_by_path('datasets/folder/dummy1.py', 'Dataset') self.assertEqual(str(type(entity)), "<class 'datasets.folder.dummy1.Dataset'>") entity = get_entity_by_path('datasets/folder/dummy2.py', 'Dataset', {}) self.assertIsNone(entity)
def test_get_entity_by_path_dashboard(self): entity = get_entity_by_path('dashboards/dummy2.py', 'Dashboard', {}) self.assertEqual(str(type(entity)), "<class 'dashboards.dummy2.Dashboard'>") entity = get_entity_by_path('dashboards/dummy1/dummy3.py', 'Dashboard', {}) self.assertEqual(str(type(entity)), "<class 'dashboards.dummy1.dummy3.Dashboard'>") entity = get_entity_by_path('dashboards/dummy1.py', 'Dashboard', {}) self.assertEqual(str(type(entity)), "<class 'dashboards.dummy1.Dashboard'>")
def report_detail_raw(request, report_path): report = get_entity_by_path('reports/{}.py'.format(report_path), 'Report', request.GET) if not report: raise Http404() return report.get_data()
def report_detail(request, report_path): report = get_entity_by_path('reports/{}.py'.format(report_path), 'Report', request.GET) if not report: raise Http404() return render(request, 'bi/report_detail.html', {'report': report})
def dashboard_detail(request, dashboard_id): dashboard = get_entity_by_path('dashboards/{}.py'.format(dashboard_id), 'Dashboard', request.GET) if not dashboard: raise Http404() return render(request, 'bi/dashboard_detail.html', {'dashboard': dashboard})
def test_get_entity_by_path_report(self): entity = get_entity_by_path('reports/dummy1.py', 'Report', {}) self.assertEqual(str(type(entity)), "<class 'reports.dummy1.Report'>") entity = get_entity_by_path('reports/dummy100.py', 'Report', {}) self.assertIsNone(entity)
def test_get_parent_dashboard_id(self): board = get_entity_by_path('dashboards/dummy1.py', 'Dashboard', {}) self.assertIsNone(board.get_parent_dashboard_id()) board = get_entity_by_path('dashboards/dummy1/dummy3.py', 'Dashboard', {}) self.assertEqual(board.get_parent_dashboard_id(), 'dummy1')
def test_template(self): board = get_entity_by_path('dashboards/dummy1.py', 'Dashboard', {}) self.assertEqual(board.template, normcase('dashboards/dummy1.html'))
def test_id(self): board = get_entity_by_path('dashboards/dummy1.py', 'Dashboard', {}) self.assertEqual(board.id, 'dummy1')
def report(report_class: Text, **kwargs): rep = get_entity_by_path('reports/{}'.format(report_class), 'Report', kwargs) context = {'report': rep} template = loader.get_template('bi/dashboard_report.html') return template.render(context)