def test_get_class_by_path_dataset(self): entity = get_class_by_path('datasets/dummy.py', 'Dataset') self.assertEqual(str(entity), "<class 'datasets.dummy.Dataset'>") entity = get_class_by_path('datasets/folder/dummy1.py', 'Dataset') self.assertEqual(str(entity), "<class 'datasets.folder.dummy1.Dataset'>")
def test_get_parent_dashboard_url(self): dummy_board1 = get_class_by_path('dashboards/dummy1.py', 'Dashboard') self.assertIsNone(dummy_board1.get_parent_dashboard_url()) dummy_board3 = get_class_by_path('dashboards/dummy1/dummy3.py', 'Dashboard') self.assertEqual(dummy_board3.get_parent_dashboard_url(), '/dashboards/dummy1/')
def test_get_class_by_path_dashboard(self): entity = get_class_by_path('dashboards/dummy2.py', 'Dashboard') self.assertEqual(str(entity), "<class 'dashboards.dummy2.Dashboard'>") entity = get_class_by_path('dashboards/dummy1/dummy3.py', 'Dashboard') self.assertEqual(str(entity), "<class 'dashboards.dummy1.dummy3.Dashboard'>") entity = get_class_by_path('dashboards/dummy1.py', 'Dashboard') self.assertEqual(str(entity), "<class 'dashboards.dummy1.Dashboard'>")
def get_parent_dashboard(cls) -> 'BaseDashboard': """Returns instance of dashboard's parent. Returns: Instance of dashboard's parent. """ module_splitted = cls.__module__.split('.') return get_class_by_path( os.path.join(*module_splitted[:-1]) + '.py', 'Dashboard')({})
def get_parent_dashboard_class(cls) -> Union[Text, None]: """Returns class of dashboard's parent. Returns: Class of dashboard's parent. """ module_splitted = cls.__module__.split('.') return get_class_by_path( os.path.join(*module_splitted[:-1]) + '.py', 'Dashboard')
def test_get_class_by_path_report(self): entity = get_class_by_path('reports/dummy1.py', 'Report') self.assertEqual(str(entity), "<class 'reports.dummy1.Report'>") entity = get_class_by_path('reports/dummy100.py', 'Report') self.assertIsNone(entity)
def test_has_parent_dashboard(self): dummy_board1 = get_class_by_path('dashboards/dummy1.py', 'Dashboard') self.assertFalse(dummy_board1.has_parent_dashboard()) dummy_board3 = get_class_by_path('dashboards/dummy1/dummy3.py', 'Dashboard') self.assertTrue(dummy_board3.has_parent_dashboard())
def test_get_parent_dashboard(self): dummy_board3_class = get_class_by_path('dashboards/dummy1/dummy3.py', 'Dashboard') self.assertEqual(str(type(dummy_board3_class.get_parent_dashboard())), "<class 'dashboards.dummy1.Dashboard'>")
def test_get_parent_dashboard_class(self): dummy_board3 = get_class_by_path('dashboards/dummy1/dummy3.py', 'Dashboard') dummy_board1 = get_class_by_path('dashboards/dummy1.py', 'Dashboard') self.assertEqual(str(dummy_board3.get_parent_dashboard_class()), str(dummy_board1))