@@ -35,6 +35,57 @@ def test_get_all_dashboards(test_linode_client):
3535 assert dashboards_by_svc [0 ].service_type == get_service_type
3636
3737
38+ def test_filter_and_group_by (test_linode_client ):
39+ client = test_linode_client
40+ dashboards_by_svc = client .monitor .dashboards (service_type = "linode" )
41+ assert isinstance (dashboards_by_svc [0 ], MonitorDashboard )
42+
43+ # Get the first dashboard for linode service type
44+ dashboard = dashboards_by_svc [0 ]
45+ assert dashboard .service_type == "linode"
46+
47+ # Ensure the dashboard has widgets
48+ assert hasattr (
49+ dashboard , "widgets"
50+ ), "Dashboard should have widgets attribute"
51+ assert dashboard .widgets is not None , "Dashboard widgets should not be None"
52+ assert (
53+ len (dashboard .widgets ) > 0
54+ ), "Dashboard should have at least one widget"
55+
56+ # Test the first widget's group_by and filters fields
57+ widget = dashboard .widgets [0 ]
58+
59+ # Test group_by field type
60+ group_by = widget .group_by
61+ assert group_by is None or isinstance (
62+ group_by , list
63+ ), "group_by should be None or list type"
64+ if group_by is not None :
65+ for item in group_by :
66+ assert isinstance (item , str ), "group_by items should be strings"
67+
68+ # Test filters field type
69+ filters = widget .filters
70+ assert filters is None or isinstance (
71+ filters , list
72+ ), "filters should be None or list type"
73+ if filters is not None :
74+ from linode_api4 .objects .monitor import Filter
75+
76+ for filter_item in filters :
77+ assert isinstance (
78+ filter_item , Filter
79+ ), "filter items should be Filter objects"
80+ assert hasattr (
81+ filter_item , "dimension_label"
82+ ), "Filter should have dimension_label"
83+ assert hasattr (
84+ filter_item , "operator"
85+ ), "Filter should have operator"
86+ assert hasattr (filter_item , "value" ), "Filter should have value"
87+
88+
3889# List supported services
3990def test_get_supported_services (test_linode_client ):
4091 client = test_linode_client
0 commit comments