Exemple #1
0
    def test_get_alarms_with_not_admin_project(self):
        # Setup
        graph = self._create_graph()
        apis = AlarmApis(graph, self.conf, self.api_lock, self._db)
        ctx = {'tenant': 'project_2', 'is_admin': False}

        # Action
        alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants=False)
        alarms = decompress_obj(alarms)['alarms']

        # Test assertions
        self.assertThat(alarms, matchers.HasLength(2))
        self._check_projects_entities(alarms, 'project_2', True)
Exemple #2
0
    def test_get_alarms_with_not_admin_project(self):
        # Setup
        graph = self._create_graph()
        apis = AlarmApis(graph, None)
        ctx = {'tenant': 'project_2', 'is_admin': False}

        # Action
        alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants=False)
        alarms = json.loads(alarms)['alarms']

        # Test assertions
        self.assertEqual(2, len(alarms))
        self._check_projects_entities(alarms, 'project_2', True)
Exemple #3
0
    def test_get_alarms_with_all_tenants(self):
        # Setup
        graph = self._create_graph()
        apis = AlarmApis(graph, None)
        ctx = {'tenant': 'project_1', 'is_admin': False}

        # Action
        alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants=True)
        alarms = json.loads(alarms)['alarms']

        # Test assertions
        self.assertThat(alarms, matchers.HasLength(5))
        self._check_projects_entities(alarms, None, True)
Exemple #4
0
    def test_get_alarms_with_all_tenants(self):
        # Setup
        graph = self._create_graph()
        apis = AlarmApis(graph, None)
        ctx = {'tenant': 'project_1', 'is_admin': False}

        # Action
        alarms = apis.get_alarms(ctx, vitrage_id='all', all_tenants='1')
        alarms = json.loads(alarms)['alarms']

        # Test assertions
        self.assertEqual(5, len(alarms))
        self._check_projects_entities(alarms, None, True)