Пример #1
0
async def test_async_list_without_params_200(async_client):
    requests = mock_query_params_all_combos(
        f"{API_BASE_URL}/v1/groups/persons", "limit=20", "offset=0")
    response = await async_client.groups.list()

    assert any([request.called for request in requests])
    assert response.status_code == 200
Пример #2
0
async def test_async_list_without_params_200(async_client):
    requests = mock_query_params_all_combos(
        f"{API_BASE_URL}/v1/entries",
        "limit=20",
        "offset=0",
        content={"results": [{"id": 1, "pid": "pid"}]},
    )
    response = await async_client.entries.list()
    assert any([request.called for request in requests])
    assert response.status_code == 200
    assert response.json()["results"][0]["id"] == 1
Пример #3
0
def test_list_with_params_200(client):
    requests = mock_query_params_all_combos(
        f"{API_BASE_URL}/v1/groups/persons",
        "limit=20",
        "offset=0",
        "pids_include=pid1,pid2".replace(",", "%2C"),
        "q=test",
    )
    response = client.groups.list(pids_include=["pid1", "pid2"], q="test")

    assert any([request.called for request in requests])
    assert response.status_code == 200
Пример #4
0
def test_not_permanent_list_200(client):
    requests = mock_query_params_all_combos(
        f"{IAM_BASE_URL}/v1/tokens",
        "permanent=false",
        "limit=20",
        "offset=0",
        content=[{
            "token": "key"
        }],
    )
    tokens = client.tokens.list(permanent=False)
    assert any([request.called for request in requests])
    assert tokens.status_code == 200
    assert tokens.json()[0]["token"] == "key"
Пример #5
0
def test_list_without_params(client):
    requests = mock_query_params_all_combos(
        f"{API_BASE_URL}/v1/notifications",
        "limit=20",
        "offset=0",
        content={"results": [{
            "id": 1,
            "name": "name"
        }]},
    )
    response = client.notifications.list()

    assert any([request.called for request in requests])
    assert response.status_code == 200
    assert response.json()["results"][0]["id"] == 1
Пример #6
0
def test_list_with_params(client):
    requests = mock_query_params_all_combos(
        f"{IAM_BASE_URL}/v1/spaces",
        "limit=20",
        "offset=20",
        "q=test",
        content={"results": [{
            "id": 1,
            "name": "name"
        }]},
    )
    response = client.spaces.list(q="test", offset=20)

    assert any([request.called for request in requests])
    assert response.status_code == 200
    assert response.json()["results"][0]["id"] == 1
Пример #7
0
async def test_async_list_with_params_200(async_client):
    requests = mock_query_params_all_combos(
        f"{API_BASE_URL}/v1/sources",
        "limit=20",
        "offset=20",
        "q=test",
        content={"results": [{
            "id": 1,
            "name": "source_name"
        }]},
    )
    response = await async_client.sources.list(q="test", offset=20)

    assert any([request.called for request in requests])
    assert response.status_code == 200
    assert response.json()["results"][0]["name"] == "source_name"
Пример #8
0
def test_sources_list_with_params_200(client):
    requests = mock_query_params_all_combos(
        f"{API_BASE_URL}/v1/sources",
        "q=test",
        "spaces_ids=1,2".replace(",", "%2C"),
        "limit=20",
        "offset=20",
        content={"results": [{
            "id": 1,
            "name": "source_name"
        }]},
    )
    response = client.sources.list(q="test", offset=20, spaces_ids=[1, 2])

    assert any([request.called for request in requests])
    assert response.status_code == 200
    assert response.json()["results"][0]["name"] == "source_name"
Пример #9
0
async def test_async_list_200(async_client):
    requests = mock_query_params_all_combos(
        f"{IAM_BASE_URL}/v1/tokens",
        "permanent=",
        "limit=20",
        "offset=0",
        content=[{
            "token": "key"
        }, {
            "token": "key2"
        }],
    )
    tokens = await async_client.tokens.list()

    assert any([request.called for request in requests])
    assert tokens.status_code == 200
    assert tokens.json()[0]["token"] == "key"
Пример #10
0
async def test_async_persons_list_without_params_200(async_client):
    requests = mock_query_params_all_combos(
        f"{API_BASE_URL}/v1/groups/persons/1/pids",
        "limit=20",
        "offset=0",
        content={
            "count": 1,
            "results": [{
                "pid": "pid",
                "pid_source": "default"
            }],
        },
    )
    response = await async_client.groups.persons(1)

    assert any([request.called for request in requests])
    assert response.status_code == 200
    assert response.json()["results"][0]["pid"] == "pid"
Пример #11
0
async def test_async_list_with_params_200(async_client):
    date_str = "2018-06-29"
    date_obj = datetime.strptime(date_str, "%Y-%m-%d")

    requests = mock_query_params_all_combos(
        f"{API_BASE_URL}/v1/entries",
        "sources_ids=1,2,3".replace(",", "%2C"),
        f"date_from={date_str}",
        "limit=20",
        "offset=0",
        content={"results": [{"id": 1, "pid": "pid"}]},
    )
    response = await async_client.entries.list(
        sources_ids=[1, 2, 3], date_from=date_obj.date()
    )
    assert any([request.called for request in requests])
    assert response.status_code == 200
    assert response.json()["results"][0]["id"] == 1
Пример #12
0
def test_persons_list_with_params_200(client):
    requests = mock_query_params_all_combos(
        f"{API_BASE_URL}/v1/groups/persons/1/pids",
        "limit=20",
        "offset=0",
        "pids=pid1,pid2".replace(",", "%2C"),
        content={
            "count": 1,
            "results": [{
                "pid": "pid",
                "pid_source": "default"
            }],
        },
    )
    response = client.groups.persons(1, pids=["pid1", "pid2"])

    assert any([request.called for request in requests])
    assert response.status_code == 200
    assert response.json()["results"][0]["pid"] == "pid"