def test_get_rca_with_all_tenants(self): # Setup graph = self._create_graph() apis = RcaApis(graph, self.conf, self.api_lock, self._db) ctx = {'tenant': 'project_1', 'is_admin': False} # Action graph_rca = apis.get_rca(ctx, root='alarm_on_host', all_tenants=True) graph_rca = json.loads(graph_rca) # Test assertions self.assertThat(graph_rca['nodes'], matchers.HasLength(5)) self._check_projects_entities(graph_rca['nodes'], None, True)
def test_get_rca_with_admin_project(self): # Setup graph = self._create_graph() apis = RcaApis(graph, None) ctx = {'tenant': 'project_1', 'is_admin': True} # Action graph_rca = apis.get_rca(ctx, root='alarm_on_host', all_tenants=False) graph_rca = json.loads(graph_rca) # Test assertions self.assertEqual(3, len(graph_rca['nodes'])) self._check_projects_entities(graph_rca['nodes'], 'project_1', True)
def test_get_rca_with_not_admin_bla_project(self): # Setup graph = self._create_graph() apis = RcaApis(graph, None) ctx = {'tenant': 'project_2', 'is_admin': False} # Action graph_rca = apis.get_rca(ctx, root='alarm_on_host', all_tenants=False) graph_rca = json.loads(graph_rca) # Test assertions self.assertThat(graph_rca['nodes'], matchers.HasLength(3)) self._check_projects_entities(graph_rca['nodes'], 'project_2', True)
def test_get_rca_with_admin_project(self): # Setup graph = self._create_graph() apis = RcaApis(graph, None) ctx = {'tenant': 'project_1', 'is_admin': True} # Action graph_rca = apis.get_rca(ctx, root='alarm_on_host', all_tenants='0') graph_rca = json.loads(graph_rca) # Test assertions self.assertEqual(3, len(graph_rca['nodes'])) self._check_projects_entities(graph_rca['nodes'], 'project_1', True)