File: test_graphql.py

package info (click to toggle)
python-gitlab 1%3A8.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,884 kB
  • sloc: python: 25,823; makefile: 171; ruby: 27; javascript: 3
file content (28 lines) | stat: -rw-r--r-- 781 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pytest

import gitlab


@pytest.fixture
def gl_gql(gitlab_url: str, gitlab_token: str) -> gitlab.GraphQL:
    return gitlab.GraphQL(gitlab_url, token=gitlab_token)


@pytest.fixture
def gl_async_gql(gitlab_url: str, gitlab_token: str) -> gitlab.AsyncGraphQL:
    return gitlab.AsyncGraphQL(gitlab_url, token=gitlab_token)


def test_query_returns_valid_response(gl_gql: gitlab.GraphQL):
    query = "query {currentUser {active}}"

    response = gl_gql.execute(query)
    assert response["currentUser"]["active"] is True


@pytest.mark.anyio
async def test_async_query_returns_valid_response(gl_async_gql: gitlab.AsyncGraphQL):
    query = "query {currentUser {active}}"

    response = await gl_async_gql.execute(query)
    assert response["currentUser"]["active"] is True