Exemple #1
0
    def test_role_list_app_owner(self, graph_client_mock):

        test_app_object_id = '11111111-2222-3333-4444-555555555555'
        test_app_app_id = '11111111-2222-3333-4444-555555555555'
        test_user_object_id = '11111111-2222-3333-4444-555555555555'

        graph_client = mock.MagicMock()
        graph_client_mock.return_value = graph_client

        app = mock.MagicMock()
        app.object_id, app.app_id = test_app_object_id, test_app_app_id

        user = mock.MagicMock()
        user.object_id = test_user_object_id

        graph_client.applications.list.return_value = [app]
        graph_client.applications.list_owners.return_value = [user]

        # action
        res = list_application_owners(mock.MagicMock(), test_app_app_id)

        # assert
        graph_client.applications.list.assert_called_once()
        graph_client.applications.list_owners.assert_called_once()

        self.assertTrue(1 == len(res))
        self.assertTrue(test_user_object_id == res[0].object_id)
    def test_role_list_app_owner(self, graph_client_mock):
        graph_client = mock.MagicMock()
        graph_client_mock.return_value = graph_client

        user = {
            "id": MOCKED_USER_ID
        }

        graph_client.application_list.return_value = [MOCKED_APP]
        graph_client.application_owner_list.return_value = [user]

        # action
        result = list_application_owners(graph_client, MOCKED_APP_APP_ID)

        # assert
        graph_client.application_list.assert_called_once()
        graph_client.application_owner_list.assert_called_once()

        assert len(result) == 1
        assert result[0]['id'] == MOCKED_USER_ID