anaplan-sdk 0.2.9__tar.gz → 0.2.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/.github/workflows/tests.yml +2 -2
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/PKG-INFO +1 -1
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_async_clients/_bulk.py +1 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_clients/_bulk.py +1 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/index.md +3 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/pyproject.toml +5 -3
- anaplan_sdk-0.2.10/tests/async/conftest.py +58 -0
- anaplan_sdk-0.2.10/tests/async/test_async_alm_client.py +28 -0
- anaplan_sdk-0.2.10/tests/async/test_async_audit_client.py +12 -0
- anaplan_sdk-0.2.10/tests/async/test_async_client.py +91 -0
- anaplan_sdk-0.2.10/tests/async/test_async_transactional_client.py +60 -0
- anaplan_sdk-0.2.10/tests/sync/conftest.py +58 -0
- anaplan_sdk-0.2.10/tests/sync/test_alm_client.py +28 -0
- anaplan_sdk-0.2.10/tests/sync/test_audit_client.py +14 -0
- {anaplan_sdk-0.2.9/tests → anaplan_sdk-0.2.10/tests/sync}/test_client.py +23 -60
- anaplan_sdk-0.2.10/tests/sync/test_transactional_client.py +58 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/uv.lock +5 -5
- anaplan_sdk-0.2.9/tests/test_alm_client.py +0 -46
- anaplan_sdk-0.2.9/tests/test_async_alm_client.py +0 -59
- anaplan_sdk-0.2.9/tests/test_async_client.py +0 -153
- anaplan_sdk-0.2.9/tests/test_async_transactional_client.py +0 -84
- anaplan_sdk-0.2.9/tests/test_transactional_client.py +0 -65
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/.github/dependabot.yml +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/.github/workflows/docs.yml +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/.github/workflows/lint.yml +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/.gitignore +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/.pre-commit-config.yaml +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/LICENSE +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/README.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/__init__.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_async_clients/__init__.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_async_clients/_alm.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_async_clients/_audit.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_async_clients/_transactional.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_auth.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_base.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_clients/__init__.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_clients/_alm.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_clients/_audit.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/_clients/_transactional.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/exceptions.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/anaplan_sdk/models.py +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/anaplan_explained.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/api/alm_client.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/api/async_alm_client.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/api/async_audit_client.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/api/async_client.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/api/async_transactional_client.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/api/audit_client.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/api/client.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/api/exceptions.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/api/models.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/api/transactional_client.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/css/styles.css +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/guides/alm.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/guides/audit.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/guides/bulk.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/guides/bulk_vs_transactional.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/guides/logging.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/guides/multiple_models.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/guides/transactional.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/img/anaplan-overview.webp +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/img/anaplan-sdk.webp +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/installation.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/docs/quickstart.md +0 -0
- {anaplan_sdk-0.2.9 → anaplan_sdk-0.2.10}/mkdocs.yml +0 -0
@@ -18,7 +18,7 @@ jobs:
|
|
18
18
|
runs-on: "ubuntu-latest"
|
19
19
|
|
20
20
|
strategy:
|
21
|
-
max-parallel:
|
21
|
+
max-parallel: 4
|
22
22
|
matrix:
|
23
23
|
python-version: [ "3.10.4", "3.11", "3.12", "3.13" ]
|
24
24
|
|
@@ -32,4 +32,4 @@ jobs:
|
|
32
32
|
pip install uv
|
33
33
|
uv sync
|
34
34
|
- name: "Run tests"
|
35
|
-
run: "uv run python -m pytest -n
|
35
|
+
run: "uv run python -m pytest -n 8 --dist loadfile tests/"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: anaplan-sdk
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.10
|
4
4
|
Summary: Provides pythonic access to the Anaplan API
|
5
5
|
Project-URL: Homepage, https://vinzenzklass.github.io/anaplan-sdk/
|
6
6
|
Project-URL: Repository, https://github.com/VinzenzKlass/anaplan-sdk
|
@@ -133,6 +133,7 @@ class AsyncClient(_AsyncBaseClient):
|
|
133
133
|
client._transactional_client = _AsyncTransactionalClient(
|
134
134
|
existing._client, model_id, existing._retry_count
|
135
135
|
)
|
136
|
+
client._alm_client = _AsyncAlmClient(existing._client, model_id, existing._retry_count)
|
136
137
|
return client
|
137
138
|
|
138
139
|
@property
|
@@ -140,6 +140,7 @@ class Client(_BaseClient):
|
|
140
140
|
client._transactional_client = _TransactionalClient(
|
141
141
|
existing._client, model_id, existing._retry_count
|
142
142
|
)
|
143
|
+
client._alm_client = _AlmClient(existing._client, model_id, existing._retry_count)
|
143
144
|
return client
|
144
145
|
|
145
146
|
@property
|
@@ -29,3 +29,6 @@ providing both synchronous and asynchronous Clients.
|
|
29
29
|
|
30
30
|
Head over to the [Quick Start](quickstart.md) to get started with the basics.
|
31
31
|
|
32
|
+
If you find any issues or feel that this SDK is not adequately covering your use case,
|
33
|
+
please [open an issue](https://github.com/VinzenzKlass/anaplan-sdk/issues/new).
|
34
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "anaplan-sdk"
|
3
|
-
version = "0.2.
|
3
|
+
version = "0.2.10"
|
4
4
|
description = "Provides pythonic access to the Anaplan API"
|
5
5
|
license = "Apache-2.0"
|
6
6
|
authors = [{ name = "Vinzenz Klass", email = "vinzenz.klass@valantic.com" }]
|
@@ -18,7 +18,7 @@ dev = [
|
|
18
18
|
"ruff>=0.9.2",
|
19
19
|
"pre-commit>=4.0.1",
|
20
20
|
"pytest>=8.3.3",
|
21
|
-
"pytest-asyncio>=0.
|
21
|
+
"pytest-asyncio>=0.26.0",
|
22
22
|
"pytest-xdist>=3.6.1",
|
23
23
|
"mkdocs>=1.6.1",
|
24
24
|
"mkdocs-material>=9.5.41",
|
@@ -76,7 +76,9 @@ skip-magic-trailing-comma = false
|
|
76
76
|
select = ["E", "F", "B", "I"]
|
77
77
|
|
78
78
|
[tool.pytest.ini_options]
|
79
|
-
|
79
|
+
asyncio_mode = "auto"
|
80
|
+
asyncio_default_fixture_loop_scope = "session"
|
81
|
+
asyncio_default_test_loop_scope = "session"
|
80
82
|
minversion = "8.0"
|
81
83
|
addopts = "-ra -q"
|
82
84
|
pythonpath = "anaplan_sdk/"
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import logging
|
2
|
+
import os
|
3
|
+
import sys
|
4
|
+
from os import getenv
|
5
|
+
|
6
|
+
import pytest
|
7
|
+
|
8
|
+
import anaplan_sdk
|
9
|
+
|
10
|
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
11
|
+
logging.getLogger("httpx").setLevel(logging.ERROR)
|
12
|
+
logging.getLogger("anaplan_sdk").setLevel(logging.INFO)
|
13
|
+
|
14
|
+
|
15
|
+
@pytest.fixture(scope="session")
|
16
|
+
def client():
|
17
|
+
return anaplan_sdk.AsyncClient(
|
18
|
+
workspace_id=getenv("ANAPLAN_SDK_TEST_WORKSPACE_ID"),
|
19
|
+
model_id=getenv("ANAPLAN_SDK_TEST_MODEL_ID"),
|
20
|
+
certificate=getenv("ANAPLAN_SDK_TEST_CERT"),
|
21
|
+
private_key=getenv("ANAPLAN_SDK_TEST_PK"),
|
22
|
+
retry_count=3,
|
23
|
+
)
|
24
|
+
|
25
|
+
|
26
|
+
@pytest.fixture(scope="session")
|
27
|
+
def broken_client():
|
28
|
+
return anaplan_sdk.AsyncClient(
|
29
|
+
workspace_id="random",
|
30
|
+
model_id="nonsense",
|
31
|
+
certificate=os.getenv("ANAPLAN_SDK_TEST_CERT"),
|
32
|
+
private_key=os.getenv("ANAPLAN_SDK_TEST_PK"),
|
33
|
+
retry_count=1,
|
34
|
+
)
|
35
|
+
|
36
|
+
|
37
|
+
@pytest.fixture(scope="session")
|
38
|
+
def test_file():
|
39
|
+
py_version = sys.version.split(" ")[0]
|
40
|
+
if "3.10" in py_version:
|
41
|
+
return 113000000061
|
42
|
+
if "3.11" in py_version:
|
43
|
+
return 113000000062
|
44
|
+
if "3.12" in py_version:
|
45
|
+
return 113000000063
|
46
|
+
return 113000000064
|
47
|
+
|
48
|
+
|
49
|
+
@pytest.fixture(scope="session")
|
50
|
+
def test_action():
|
51
|
+
py_version = sys.version.split(" ")[0]
|
52
|
+
if "3.10" in py_version:
|
53
|
+
return 118000000028
|
54
|
+
if "3.11" in py_version:
|
55
|
+
return 118000000027
|
56
|
+
if "3.12" in py_version:
|
57
|
+
return 118000000026
|
58
|
+
return 118000000025
|
@@ -0,0 +1,28 @@
|
|
1
|
+
from anaplan_sdk import AsyncClient
|
2
|
+
|
3
|
+
|
4
|
+
async def test_get_revisions(client: AsyncClient):
|
5
|
+
revs = await client.alm.get_revisions()
|
6
|
+
assert isinstance(revs, list)
|
7
|
+
assert len(revs) > 0
|
8
|
+
|
9
|
+
|
10
|
+
async def test_get_models_for_revision(client: AsyncClient):
|
11
|
+
model_revs = await client.alm.get_models_for_revision("44867AAA4DD94C6EB8A23690A0C11DF4")
|
12
|
+
assert isinstance(model_revs, list)
|
13
|
+
assert len(model_revs) > 0
|
14
|
+
|
15
|
+
|
16
|
+
async def test_get_sync_tasks(client: AsyncClient):
|
17
|
+
tasks = await client.alm.get_sync_tasks()
|
18
|
+
assert isinstance(tasks, list)
|
19
|
+
|
20
|
+
|
21
|
+
async def test_get_syncable_revisions(client: AsyncClient):
|
22
|
+
models = await client.alm.get_syncable_revisions("327F80BA66344A1C84C69AE82C006CDE")
|
23
|
+
assert isinstance(models, list)
|
24
|
+
|
25
|
+
|
26
|
+
async def test_get_latest_revision(client: AsyncClient):
|
27
|
+
revs = await client.alm.get_latest_revision()
|
28
|
+
assert isinstance(revs, list)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from anaplan_sdk import AsyncClient, models
|
2
|
+
|
3
|
+
|
4
|
+
async def test_list_users(client: AsyncClient):
|
5
|
+
users = await client.audit.list_users()
|
6
|
+
assert isinstance(users, list)
|
7
|
+
assert isinstance(users[0], models.User)
|
8
|
+
|
9
|
+
|
10
|
+
async def test_events(client: AsyncClient):
|
11
|
+
events = await client.audit.get_events(1)
|
12
|
+
assert isinstance(events, list)
|
@@ -0,0 +1,91 @@
|
|
1
|
+
from anaplan_sdk import AsyncClient
|
2
|
+
from anaplan_sdk.exceptions import InvalidIdentifierException
|
3
|
+
|
4
|
+
|
5
|
+
async def test_list_workspaces(client: AsyncClient):
|
6
|
+
workspaces = await client.list_workspaces()
|
7
|
+
assert isinstance(workspaces, list)
|
8
|
+
assert len(workspaces) > 0
|
9
|
+
|
10
|
+
|
11
|
+
async def test_broken_list_workspaces_raises_invalid_identifier_error(broken_client):
|
12
|
+
try:
|
13
|
+
await broken_client.list_workspaces()
|
14
|
+
except Exception as error:
|
15
|
+
assert isinstance(error, InvalidIdentifierException)
|
16
|
+
|
17
|
+
|
18
|
+
async def test_list_models(client: AsyncClient):
|
19
|
+
models = await client.list_models()
|
20
|
+
assert isinstance(models, list)
|
21
|
+
assert len(models) > 0
|
22
|
+
|
23
|
+
|
24
|
+
async def test_list_actions(client: AsyncClient):
|
25
|
+
actions = await client.list_actions()
|
26
|
+
assert isinstance(actions, list)
|
27
|
+
assert len(actions) > 0
|
28
|
+
|
29
|
+
|
30
|
+
async def test_list_files(client: AsyncClient):
|
31
|
+
files = await client.list_files()
|
32
|
+
assert isinstance(files, list)
|
33
|
+
assert len(files) > 0
|
34
|
+
|
35
|
+
|
36
|
+
async def test_list_processes(client: AsyncClient):
|
37
|
+
processes = await client.list_processes()
|
38
|
+
assert isinstance(processes, list)
|
39
|
+
assert len(processes) > 0
|
40
|
+
|
41
|
+
|
42
|
+
async def test_list_imports(client: AsyncClient):
|
43
|
+
imports = await client.list_imports()
|
44
|
+
assert isinstance(imports, list)
|
45
|
+
assert len(imports) > 0
|
46
|
+
|
47
|
+
|
48
|
+
async def test_list_exports(client: AsyncClient):
|
49
|
+
exports = await client.list_exports()
|
50
|
+
assert isinstance(exports, list)
|
51
|
+
assert len(exports) > 0
|
52
|
+
|
53
|
+
|
54
|
+
async def test_upload_file_stream(client, test_file):
|
55
|
+
await client.upload_file_stream(test_file, (i async for i in _async_range(10)))
|
56
|
+
out = await client.get_file(test_file)
|
57
|
+
assert out == b"0123456789"
|
58
|
+
|
59
|
+
|
60
|
+
async def test_get_file_stream(client, test_file):
|
61
|
+
async for chunk in client.get_file_stream(test_file):
|
62
|
+
assert isinstance(chunk, bytes)
|
63
|
+
|
64
|
+
|
65
|
+
async def test_upload_and_download_file(client, test_file):
|
66
|
+
await client.upload_file(test_file, "Hi!")
|
67
|
+
out = await client.get_file(test_file)
|
68
|
+
assert out == b"Hi!"
|
69
|
+
|
70
|
+
|
71
|
+
async def test_run_process(client, test_action):
|
72
|
+
await client.run_action(test_action)
|
73
|
+
|
74
|
+
|
75
|
+
async def test_invoke_action(client, test_action):
|
76
|
+
task_id = await client.invoke_action(test_action)
|
77
|
+
assert isinstance(task_id, str)
|
78
|
+
assert len(task_id) == 32
|
79
|
+
|
80
|
+
|
81
|
+
async def test_get_task_status(client, test_action):
|
82
|
+
task_status = await client.get_task_status(test_action, await client.invoke_action(test_action))
|
83
|
+
assert isinstance(task_status, dict)
|
84
|
+
assert "progress" in task_status
|
85
|
+
assert "creationTime" in task_status
|
86
|
+
assert "taskState" in task_status
|
87
|
+
|
88
|
+
|
89
|
+
async def _async_range(count: int):
|
90
|
+
for i in range(count):
|
91
|
+
yield str(i)
|
@@ -0,0 +1,60 @@
|
|
1
|
+
from uuid import uuid4
|
2
|
+
|
3
|
+
from anaplan_sdk import AsyncClient
|
4
|
+
from anaplan_sdk.models import InsertionResult, ListMetadata, ModelStatus
|
5
|
+
|
6
|
+
|
7
|
+
async def test_list_workspaces(client: AsyncClient):
|
8
|
+
modules = await client.transactional.list_modules()
|
9
|
+
assert isinstance(modules, list)
|
10
|
+
assert len(modules) > 0
|
11
|
+
|
12
|
+
|
13
|
+
async def test_list_lists(client: AsyncClient):
|
14
|
+
lists = await client.transactional.list_lists()
|
15
|
+
assert isinstance(lists, list)
|
16
|
+
assert len(lists) > 0
|
17
|
+
|
18
|
+
|
19
|
+
async def test_list_line_items(client: AsyncClient):
|
20
|
+
items = await client.transactional.list_line_items()
|
21
|
+
assert isinstance(items, list)
|
22
|
+
assert len(items) > 0
|
23
|
+
|
24
|
+
|
25
|
+
async def test_get_list_items(client: AsyncClient):
|
26
|
+
items = await client.transactional.get_list_items(101000000009)
|
27
|
+
assert isinstance(items, list)
|
28
|
+
|
29
|
+
|
30
|
+
async def test_get_list_meta(client: AsyncClient):
|
31
|
+
meta = await client.transactional.get_list_metadata(101000000009)
|
32
|
+
assert isinstance(meta, ListMetadata)
|
33
|
+
|
34
|
+
|
35
|
+
async def test_get_model_status(client: AsyncClient):
|
36
|
+
status = await client.transactional.get_model_status()
|
37
|
+
assert isinstance(status, ModelStatus)
|
38
|
+
|
39
|
+
|
40
|
+
async def test_list_insertion(client: AsyncClient):
|
41
|
+
result = await client.transactional.add_items_to_list(
|
42
|
+
101000000009, [{"code": str(uuid4()), "name": str(uuid4())}]
|
43
|
+
)
|
44
|
+
assert isinstance(result, InsertionResult)
|
45
|
+
assert result.failures == []
|
46
|
+
assert result.added == 1
|
47
|
+
assert result.ignored == 0
|
48
|
+
assert result.total == 1
|
49
|
+
|
50
|
+
|
51
|
+
async def test_delete_list_items(client: AsyncClient):
|
52
|
+
code = str(uuid4())
|
53
|
+
await client.transactional.add_items_to_list(
|
54
|
+
101000000009, [{"code": code, "name": str(uuid4())}]
|
55
|
+
)
|
56
|
+
await client.transactional.delete_list_items(101000000009, [{"code": code}])
|
57
|
+
|
58
|
+
|
59
|
+
async def test_reset_list_index(client: AsyncClient):
|
60
|
+
await client.transactional.reset_list_index(101000000010)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import logging
|
2
|
+
import os
|
3
|
+
import sys
|
4
|
+
from os import getenv
|
5
|
+
|
6
|
+
import pytest
|
7
|
+
|
8
|
+
import anaplan_sdk
|
9
|
+
|
10
|
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
11
|
+
logging.getLogger("httpx").setLevel(logging.ERROR)
|
12
|
+
logging.getLogger("anaplan_sdk").setLevel(logging.INFO)
|
13
|
+
|
14
|
+
|
15
|
+
@pytest.fixture(scope="session")
|
16
|
+
def client():
|
17
|
+
return anaplan_sdk.Client(
|
18
|
+
workspace_id=getenv("ANAPLAN_SDK_TEST_WORKSPACE_ID"),
|
19
|
+
model_id=getenv("ANAPLAN_SDK_TEST_MODEL_ID"),
|
20
|
+
certificate=getenv("ANAPLAN_SDK_TEST_CERT"),
|
21
|
+
private_key=getenv("ANAPLAN_SDK_TEST_PK"),
|
22
|
+
retry_count=3,
|
23
|
+
)
|
24
|
+
|
25
|
+
|
26
|
+
@pytest.fixture(scope="session")
|
27
|
+
def broken_client():
|
28
|
+
return anaplan_sdk.Client(
|
29
|
+
workspace_id="random",
|
30
|
+
model_id="nonsense",
|
31
|
+
certificate=os.getenv("ANAPLAN_SDK_TEST_CERT"),
|
32
|
+
private_key=os.getenv("ANAPLAN_SDK_TEST_PK"),
|
33
|
+
retry_count=1,
|
34
|
+
)
|
35
|
+
|
36
|
+
|
37
|
+
@pytest.fixture(scope="session")
|
38
|
+
def test_file():
|
39
|
+
py_version = sys.version.split(" ")[0]
|
40
|
+
if "3.10" in py_version:
|
41
|
+
return 113000000065
|
42
|
+
if "3.11" in py_version:
|
43
|
+
return 113000000066
|
44
|
+
if "3.12" in py_version:
|
45
|
+
return 113000000067
|
46
|
+
return 113000000068
|
47
|
+
|
48
|
+
|
49
|
+
@pytest.fixture(scope="session")
|
50
|
+
def test_action():
|
51
|
+
py_version = sys.version.split(" ")[0]
|
52
|
+
if "3.10" in py_version:
|
53
|
+
return 118000000024
|
54
|
+
if "3.11" in py_version:
|
55
|
+
return 118000000023
|
56
|
+
if "3.12" in py_version:
|
57
|
+
return 118000000022
|
58
|
+
return 118000000021
|
@@ -0,0 +1,28 @@
|
|
1
|
+
from anaplan_sdk import Client
|
2
|
+
|
3
|
+
|
4
|
+
def test_get_revisions(client: Client):
|
5
|
+
revs = client.alm.get_revisions()
|
6
|
+
assert isinstance(revs, list)
|
7
|
+
assert len(revs) > 0
|
8
|
+
|
9
|
+
|
10
|
+
def test_get_models_for_revision(client: Client):
|
11
|
+
model_revs = client.alm.get_models_for_revision("44867AAA4DD94C6EB8A23690A0C11DF4")
|
12
|
+
assert isinstance(model_revs, list)
|
13
|
+
assert len(model_revs) > 0
|
14
|
+
|
15
|
+
|
16
|
+
def test_get_sync_tasks(client: Client):
|
17
|
+
tasks = client.alm.get_sync_tasks()
|
18
|
+
assert isinstance(tasks, list)
|
19
|
+
|
20
|
+
|
21
|
+
def test_get_syncable_revisions(client: Client):
|
22
|
+
models = client.alm.get_syncable_revisions("327F80BA66344A1C84C69AE82C006CDE")
|
23
|
+
assert isinstance(models, list)
|
24
|
+
|
25
|
+
|
26
|
+
def test_get_latest_revision(client: Client):
|
27
|
+
revs = client.alm.get_latest_revision()
|
28
|
+
assert isinstance(revs, list)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from anaplan_sdk import Client
|
2
|
+
from anaplan_sdk.models import User
|
3
|
+
|
4
|
+
|
5
|
+
def test_list_users(client: Client):
|
6
|
+
users = client.audit.list_users()
|
7
|
+
assert isinstance(users, list)
|
8
|
+
assert isinstance(users[0], User)
|
9
|
+
assert len(users) > 0
|
10
|
+
|
11
|
+
|
12
|
+
def test_events(client: Client):
|
13
|
+
events = client.audit.get_events(1)
|
14
|
+
assert isinstance(events, list)
|
@@ -1,123 +1,86 @@
|
|
1
|
-
import
|
2
|
-
import sys
|
3
|
-
|
4
|
-
import anaplan_sdk
|
1
|
+
from anaplan_sdk import Client
|
5
2
|
from anaplan_sdk.exceptions import InvalidIdentifierException
|
6
3
|
|
7
|
-
client = anaplan_sdk.Client(
|
8
|
-
workspace_id=os.getenv("ANAPLAN_SDK_TEST_WORKSPACE_ID"),
|
9
|
-
model_id=os.getenv("ANAPLAN_SDK_TEST_MODEL_ID"),
|
10
|
-
certificate=os.getenv("ANAPLAN_SDK_TEST_CERT"),
|
11
|
-
private_key=os.getenv("ANAPLAN_SDK_TEST_PK"),
|
12
|
-
retry_count=3,
|
13
|
-
)
|
14
|
-
|
15
|
-
broken_client = anaplan_sdk.Client(
|
16
|
-
workspace_id="random",
|
17
|
-
model_id="nonsense",
|
18
|
-
certificate=os.getenv("ANAPLAN_SDK_TEST_CERT"),
|
19
|
-
private_key=os.getenv("ANAPLAN_SDK_TEST_PK"),
|
20
|
-
retry_count=1,
|
21
|
-
)
|
22
|
-
|
23
|
-
py_version = sys.version.split(" ")[0]
|
24
|
-
if "3.12" in py_version:
|
25
|
-
test_file = 113000000031
|
26
|
-
test_action = 118000000007
|
27
|
-
|
28
|
-
elif "3.11" in py_version:
|
29
|
-
test_file = 113000000030
|
30
|
-
test_action = 118000000008
|
31
|
-
else:
|
32
|
-
test_file = 113000000029
|
33
|
-
test_action = 118000000006
|
34
|
-
|
35
|
-
|
36
|
-
def test_unauthorized_client_raises_value_error():
|
37
|
-
try:
|
38
|
-
anaplan_sdk.Client()
|
39
|
-
except Exception as error:
|
40
|
-
assert isinstance(error, ValueError)
|
41
|
-
|
42
4
|
|
43
|
-
def test_list_workspaces():
|
5
|
+
def test_list_workspaces(client: Client):
|
44
6
|
workspaces = client.list_workspaces()
|
45
7
|
assert isinstance(workspaces, list)
|
46
8
|
assert len(workspaces) > 0
|
47
9
|
|
48
10
|
|
49
|
-
def test_broken_list_workspaces_raises_invalid_identifier_error():
|
11
|
+
def test_broken_list_workspaces_raises_invalid_identifier_error(broken_client: Client):
|
50
12
|
try:
|
51
13
|
broken_client.list_workspaces()
|
52
14
|
except Exception as error:
|
53
15
|
assert isinstance(error, InvalidIdentifierException)
|
54
16
|
|
55
17
|
|
56
|
-
def test_list_models():
|
18
|
+
def test_list_models(client: Client):
|
57
19
|
models = client.list_models()
|
58
20
|
assert isinstance(models, list)
|
59
21
|
assert len(models) > 0
|
60
22
|
|
61
23
|
|
62
|
-
def test_list_actions():
|
24
|
+
def test_list_actions(client: Client):
|
63
25
|
actions = client.list_actions()
|
64
26
|
assert isinstance(actions, list)
|
65
27
|
assert len(actions) > 0
|
66
28
|
|
67
29
|
|
68
|
-
def test_list_files():
|
30
|
+
def test_list_files(client: Client):
|
69
31
|
files = client.list_files()
|
70
32
|
assert isinstance(files, list)
|
71
33
|
assert len(files) > 0
|
72
34
|
|
73
35
|
|
74
|
-
def test_list_processes():
|
36
|
+
def test_list_processes(client: Client):
|
75
37
|
processes = client.list_processes()
|
76
38
|
assert isinstance(processes, list)
|
77
39
|
assert len(processes) > 0
|
78
40
|
|
79
41
|
|
80
|
-
def test_list_imports():
|
42
|
+
def test_list_imports(client: Client):
|
81
43
|
imports = client.list_imports()
|
82
44
|
assert isinstance(imports, list)
|
83
45
|
assert len(imports) > 0
|
84
46
|
|
85
47
|
|
86
|
-
def test_list_exports():
|
48
|
+
def test_list_exports(client: Client):
|
87
49
|
exports = client.list_exports()
|
88
50
|
assert isinstance(exports, list)
|
89
51
|
assert len(exports) > 0
|
90
52
|
|
91
53
|
|
92
|
-
def
|
93
|
-
client.upload_file(test_file, "Hi!")
|
94
|
-
out = client.get_file(test_file)
|
95
|
-
assert out == b"Hi!"
|
96
|
-
|
97
|
-
|
98
|
-
def test_upload_file_stream():
|
54
|
+
def test_upload_file_stream(client: Client, test_file):
|
99
55
|
client.upload_file_stream(test_file, (str(i) for i in range(10)))
|
100
56
|
out = client.get_file(test_file)
|
101
57
|
assert out == b"0123456789"
|
102
58
|
|
103
59
|
|
104
|
-
def test_get_file_stream():
|
60
|
+
def test_get_file_stream(client: Client, test_file):
|
105
61
|
for chunk in client.get_file_stream(test_file):
|
106
62
|
assert isinstance(chunk, bytes)
|
107
63
|
|
108
64
|
|
109
|
-
def
|
65
|
+
def test_upload_and_download_file(client: Client, test_file):
|
66
|
+
client.upload_file(test_file, "Hi!")
|
67
|
+
out = client.get_file(test_file)
|
68
|
+
assert out == b"Hi!"
|
69
|
+
|
70
|
+
|
71
|
+
def test_run_process(client: Client, test_action):
|
110
72
|
client.run_action(test_action)
|
111
73
|
|
112
74
|
|
113
|
-
def test_invoke_action():
|
75
|
+
def test_invoke_action(client: Client, test_action):
|
114
76
|
task_id = client.invoke_action(test_action)
|
115
77
|
assert isinstance(task_id, str)
|
116
78
|
assert len(task_id) == 32
|
117
79
|
|
118
80
|
|
119
|
-
def test_get_task_status():
|
81
|
+
def test_get_task_status(client: Client, test_action):
|
120
82
|
task_status = client.get_task_status(test_action, client.invoke_action(test_action))
|
121
83
|
assert isinstance(task_status, dict)
|
122
|
-
assert "
|
123
|
-
assert "
|
84
|
+
assert "progress" in task_status
|
85
|
+
assert "creationTime" in task_status
|
86
|
+
assert "taskState" in task_status
|
@@ -0,0 +1,58 @@
|
|
1
|
+
from uuid import uuid4
|
2
|
+
|
3
|
+
from anaplan_sdk import Client
|
4
|
+
from anaplan_sdk.models import InsertionResult, ListMetadata, ModelStatus
|
5
|
+
|
6
|
+
|
7
|
+
def test_list_workspaces(client: Client):
|
8
|
+
modules = client.transactional.list_modules()
|
9
|
+
assert isinstance(modules, list)
|
10
|
+
assert len(modules) > 0
|
11
|
+
|
12
|
+
|
13
|
+
def test_list_lists(client: Client):
|
14
|
+
lists = client.transactional.list_lists()
|
15
|
+
assert isinstance(lists, list)
|
16
|
+
assert len(lists) > 0
|
17
|
+
|
18
|
+
|
19
|
+
def test_list_line_items(client: Client):
|
20
|
+
items = client.transactional.list_line_items()
|
21
|
+
assert isinstance(items, list)
|
22
|
+
assert len(items) > 0
|
23
|
+
|
24
|
+
|
25
|
+
def test_get_list_items(client: Client):
|
26
|
+
items = client.transactional.get_list_items(101000000009)
|
27
|
+
assert isinstance(items, list)
|
28
|
+
|
29
|
+
|
30
|
+
def test_get_list_meta(client: Client):
|
31
|
+
meta = client.transactional.get_list_metadata(101000000009)
|
32
|
+
assert isinstance(meta, ListMetadata)
|
33
|
+
|
34
|
+
|
35
|
+
def test_get_model_status(client: Client):
|
36
|
+
status = client.transactional.get_model_status()
|
37
|
+
assert isinstance(status, ModelStatus)
|
38
|
+
|
39
|
+
|
40
|
+
def test_list_insertion(client: Client):
|
41
|
+
result = client.transactional.add_items_to_list(
|
42
|
+
101000000009, [{"code": str(uuid4()), "name": str(uuid4())}]
|
43
|
+
)
|
44
|
+
assert isinstance(result, InsertionResult)
|
45
|
+
assert result.failures == []
|
46
|
+
assert result.added == 1
|
47
|
+
assert result.ignored == 0
|
48
|
+
assert result.total == 1
|
49
|
+
|
50
|
+
|
51
|
+
def test_delete_list_items(client: Client):
|
52
|
+
code = str(uuid4())
|
53
|
+
client.transactional.add_items_to_list(101000000009, [{"code": code, "name": str(uuid4())}])
|
54
|
+
client.transactional.delete_list_items(101000000009, [{"code": code}])
|
55
|
+
|
56
|
+
|
57
|
+
def test_reset_list_index(client: Client):
|
58
|
+
client.transactional.reset_list_index(101000000010)
|
@@ -3,7 +3,7 @@ requires-python = ">=3.10.4"
|
|
3
3
|
|
4
4
|
[[package]]
|
5
5
|
name = "anaplan-sdk"
|
6
|
-
version = "0.2.
|
6
|
+
version = "0.2.10"
|
7
7
|
source = { editable = "." }
|
8
8
|
dependencies = [
|
9
9
|
{ name = "cryptography" },
|
@@ -39,7 +39,7 @@ dev = [
|
|
39
39
|
{ name = "polars", specifier = ">=1.25.2" },
|
40
40
|
{ name = "pre-commit", specifier = ">=4.0.1" },
|
41
41
|
{ name = "pytest", specifier = ">=8.3.3" },
|
42
|
-
{ name = "pytest-asyncio", specifier = ">=0.
|
42
|
+
{ name = "pytest-asyncio", specifier = ">=0.26.0" },
|
43
43
|
{ name = "pytest-xdist", specifier = ">=3.6.1" },
|
44
44
|
{ name = "ruff", specifier = ">=0.9.2" },
|
45
45
|
]
|
@@ -847,14 +847,14 @@ wheels = [
|
|
847
847
|
|
848
848
|
[[package]]
|
849
849
|
name = "pytest-asyncio"
|
850
|
-
version = "0.
|
850
|
+
version = "0.26.0"
|
851
851
|
source = { registry = "https://pypi.org/simple" }
|
852
852
|
dependencies = [
|
853
853
|
{ name = "pytest" },
|
854
854
|
]
|
855
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
855
|
+
sdist = { url = "https://files.pythonhosted.org/packages/8e/c4/453c52c659521066969523e87d85d54139bbd17b78f09532fb8eb8cdb58e/pytest_asyncio-0.26.0.tar.gz", hash = "sha256:c4df2a697648241ff39e7f0e4a73050b03f123f760673956cf0d72a4990e312f", size = 54156 }
|
856
856
|
wheels = [
|
857
|
-
{ url = "https://files.pythonhosted.org/packages/
|
857
|
+
{ url = "https://files.pythonhosted.org/packages/20/7f/338843f449ace853647ace35870874f69a764d251872ed1b4de9f234822c/pytest_asyncio-0.26.0-py3-none-any.whl", hash = "sha256:7b51ed894f4fbea1340262bdae5135797ebbe21d8638978e35d31c6d19f72fb0", size = 19694 },
|
858
858
|
]
|
859
859
|
|
860
860
|
[[package]]
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
|
3
|
-
import anaplan_sdk
|
4
|
-
from anaplan_sdk.models import User
|
5
|
-
|
6
|
-
client = anaplan_sdk.Client(
|
7
|
-
workspace_id=os.getenv("ANAPLAN_SDK_TEST_WORKSPACE_ID"),
|
8
|
-
model_id=os.getenv("ANAPLAN_SDK_TEST_MODEL_ID"),
|
9
|
-
certificate=os.getenv("ANAPLAN_SDK_TEST_CERT"),
|
10
|
-
private_key=os.getenv("ANAPLAN_SDK_TEST_PK"),
|
11
|
-
retry_count=3,
|
12
|
-
).alm
|
13
|
-
|
14
|
-
|
15
|
-
def test_list_users():
|
16
|
-
revs = client.list_users()
|
17
|
-
assert isinstance(revs, list)
|
18
|
-
assert isinstance(revs[0], User)
|
19
|
-
assert len(revs) > 0
|
20
|
-
|
21
|
-
|
22
|
-
def test_get_revisions():
|
23
|
-
revs = client.get_revisions()
|
24
|
-
assert isinstance(revs, list)
|
25
|
-
assert len(revs) > 0
|
26
|
-
|
27
|
-
|
28
|
-
def test_get_models_for_revision():
|
29
|
-
model_revs = client.get_models_for_revision("44867AAA4DD94C6EB8A23690A0C11DF4")
|
30
|
-
assert isinstance(model_revs, list)
|
31
|
-
assert len(model_revs) > 0
|
32
|
-
|
33
|
-
|
34
|
-
def test_get_sync_tasks():
|
35
|
-
tasks = client.get_sync_tasks()
|
36
|
-
assert isinstance(tasks, list)
|
37
|
-
|
38
|
-
|
39
|
-
def test_get_syncable_revisions():
|
40
|
-
models = client.get_syncable_revisions("327F80BA66344A1C84C69AE82C006CDE")
|
41
|
-
assert isinstance(models, list)
|
42
|
-
|
43
|
-
|
44
|
-
def test_get_latest_revision():
|
45
|
-
revs = client.get_latest_revision()
|
46
|
-
assert isinstance(revs, list)
|
@@ -1,59 +0,0 @@
|
|
1
|
-
import asyncio
|
2
|
-
import os
|
3
|
-
|
4
|
-
import pytest
|
5
|
-
|
6
|
-
import anaplan_sdk
|
7
|
-
from anaplan_sdk.models import User
|
8
|
-
|
9
|
-
client = anaplan_sdk.AsyncClient(
|
10
|
-
workspace_id=os.getenv("ANAPLAN_SDK_TEST_WORKSPACE_ID"),
|
11
|
-
model_id=os.getenv("ANAPLAN_SDK_TEST_MODEL_ID"),
|
12
|
-
certificate=os.getenv("ANAPLAN_SDK_TEST_CERT"),
|
13
|
-
private_key=os.getenv("ANAPLAN_SDK_TEST_PK"),
|
14
|
-
retry_count=3,
|
15
|
-
).alm
|
16
|
-
|
17
|
-
|
18
|
-
@pytest.fixture(scope="module")
|
19
|
-
def event_loop():
|
20
|
-
yield asyncio.get_event_loop()
|
21
|
-
|
22
|
-
|
23
|
-
@pytest.mark.asyncio
|
24
|
-
async def test_list_users():
|
25
|
-
revs = await client.list_users()
|
26
|
-
assert isinstance(revs, list)
|
27
|
-
assert isinstance(revs[0], User)
|
28
|
-
|
29
|
-
|
30
|
-
@pytest.mark.asyncio
|
31
|
-
async def test_get_revisions():
|
32
|
-
revs = await client.get_revisions()
|
33
|
-
assert isinstance(revs, list)
|
34
|
-
assert len(revs) > 0
|
35
|
-
|
36
|
-
|
37
|
-
@pytest.mark.asyncio
|
38
|
-
async def test_get_models_for_revision():
|
39
|
-
model_revs = await client.get_models_for_revision("44867AAA4DD94C6EB8A23690A0C11DF4")
|
40
|
-
assert isinstance(model_revs, list)
|
41
|
-
assert len(model_revs) > 0
|
42
|
-
|
43
|
-
|
44
|
-
@pytest.mark.asyncio
|
45
|
-
async def test_get_sync_tasks():
|
46
|
-
tasks = await client.get_sync_tasks()
|
47
|
-
assert isinstance(tasks, list)
|
48
|
-
|
49
|
-
|
50
|
-
@pytest.mark.asyncio
|
51
|
-
async def test_get_syncable_revisions():
|
52
|
-
models = await client.get_syncable_revisions("327F80BA66344A1C84C69AE82C006CDE")
|
53
|
-
assert isinstance(models, list)
|
54
|
-
|
55
|
-
|
56
|
-
@pytest.mark.asyncio
|
57
|
-
async def test_get_latest_revision():
|
58
|
-
revs = await client.get_latest_revision()
|
59
|
-
assert isinstance(revs, list)
|
@@ -1,153 +0,0 @@
|
|
1
|
-
import asyncio
|
2
|
-
import os
|
3
|
-
import sys
|
4
|
-
|
5
|
-
import pytest
|
6
|
-
|
7
|
-
import anaplan_sdk
|
8
|
-
from anaplan_sdk.exceptions import InvalidIdentifierException
|
9
|
-
|
10
|
-
client = anaplan_sdk.AsyncClient(
|
11
|
-
workspace_id=os.getenv("ANAPLAN_SDK_TEST_WORKSPACE_ID"),
|
12
|
-
model_id=os.getenv("ANAPLAN_SDK_TEST_MODEL_ID"),
|
13
|
-
certificate=os.getenv("ANAPLAN_SDK_TEST_CERT"),
|
14
|
-
private_key=os.getenv("ANAPLAN_SDK_TEST_PK"),
|
15
|
-
retry_count=3,
|
16
|
-
)
|
17
|
-
|
18
|
-
broken_client = anaplan_sdk.AsyncClient(
|
19
|
-
workspace_id="random",
|
20
|
-
model_id="nonsense",
|
21
|
-
certificate=os.getenv("ANAPLAN_SDK_TEST_CERT"),
|
22
|
-
private_key=os.getenv("ANAPLAN_SDK_TEST_PK"),
|
23
|
-
retry_count=1,
|
24
|
-
)
|
25
|
-
|
26
|
-
|
27
|
-
pytest_plugins = ("pytest_asyncio",)
|
28
|
-
|
29
|
-
py_version = sys.version.split(" ")[0]
|
30
|
-
if "3.12" in py_version:
|
31
|
-
test_file = 113000000031
|
32
|
-
test_action = 118000000007
|
33
|
-
|
34
|
-
elif "3.11" in py_version:
|
35
|
-
test_file = 113000000030
|
36
|
-
test_action = 118000000008
|
37
|
-
else:
|
38
|
-
test_file = 113000000029
|
39
|
-
test_action = 118000000006
|
40
|
-
|
41
|
-
|
42
|
-
@pytest.fixture(scope="module")
|
43
|
-
def event_loop():
|
44
|
-
yield asyncio.get_event_loop()
|
45
|
-
|
46
|
-
|
47
|
-
def test_unauthorized_client_raises_value_error():
|
48
|
-
try:
|
49
|
-
anaplan_sdk.Client()
|
50
|
-
except Exception as error:
|
51
|
-
assert isinstance(error, ValueError)
|
52
|
-
|
53
|
-
|
54
|
-
@pytest.mark.asyncio
|
55
|
-
async def test_list_workspaces():
|
56
|
-
workspaces = await client.list_workspaces()
|
57
|
-
assert isinstance(workspaces, list)
|
58
|
-
assert len(workspaces) > 0
|
59
|
-
|
60
|
-
|
61
|
-
@pytest.mark.asyncio
|
62
|
-
async def test_broken_list_workspaces_raises_invalid_identifier_error():
|
63
|
-
try:
|
64
|
-
await broken_client.list_workspaces()
|
65
|
-
except Exception as error:
|
66
|
-
assert isinstance(error, InvalidIdentifierException)
|
67
|
-
|
68
|
-
|
69
|
-
@pytest.mark.asyncio
|
70
|
-
async def test_list_models():
|
71
|
-
models = await client.list_models()
|
72
|
-
assert isinstance(models, list)
|
73
|
-
assert len(models) > 0
|
74
|
-
|
75
|
-
|
76
|
-
@pytest.mark.asyncio
|
77
|
-
async def test_list_actions():
|
78
|
-
actions = await client.list_actions()
|
79
|
-
assert isinstance(actions, list)
|
80
|
-
assert len(actions) > 0
|
81
|
-
|
82
|
-
|
83
|
-
@pytest.mark.asyncio
|
84
|
-
async def test_list_files():
|
85
|
-
files = await client.list_files()
|
86
|
-
assert isinstance(files, list)
|
87
|
-
assert len(files) > 0
|
88
|
-
|
89
|
-
|
90
|
-
@pytest.mark.asyncio
|
91
|
-
async def test_list_processes():
|
92
|
-
processes = await client.list_processes()
|
93
|
-
assert isinstance(processes, list)
|
94
|
-
assert len(processes) > 0
|
95
|
-
|
96
|
-
|
97
|
-
@pytest.mark.asyncio
|
98
|
-
async def test_list_imports():
|
99
|
-
imports = await client.list_imports()
|
100
|
-
assert isinstance(imports, list)
|
101
|
-
assert len(imports) > 0
|
102
|
-
|
103
|
-
|
104
|
-
@pytest.mark.asyncio
|
105
|
-
async def test_list_exports():
|
106
|
-
exports = await client.list_exports()
|
107
|
-
assert isinstance(exports, list)
|
108
|
-
assert len(exports) > 0
|
109
|
-
|
110
|
-
|
111
|
-
@pytest.mark.asyncio
|
112
|
-
async def test_upload_and_download_file():
|
113
|
-
await client.upload_file(test_file, "Hi!")
|
114
|
-
out = await client.get_file(test_file)
|
115
|
-
assert out == b"Hi!"
|
116
|
-
|
117
|
-
|
118
|
-
@pytest.mark.asyncio
|
119
|
-
async def test_upload_file_stream():
|
120
|
-
await client.upload_file_stream(113000000000, (i async for i in _async_range(10)))
|
121
|
-
out = await client.get_file(113000000000)
|
122
|
-
assert out == b"0123456789"
|
123
|
-
|
124
|
-
|
125
|
-
@pytest.mark.asyncio
|
126
|
-
async def test_get_file_stream():
|
127
|
-
async for chunk in client.get_file_stream(113000000000):
|
128
|
-
assert isinstance(chunk, bytes)
|
129
|
-
|
130
|
-
|
131
|
-
@pytest.mark.asyncio
|
132
|
-
async def test_run_process():
|
133
|
-
await client.run_action(test_action)
|
134
|
-
|
135
|
-
|
136
|
-
@pytest.mark.asyncio
|
137
|
-
async def test_invoke_action():
|
138
|
-
task_id = await client.invoke_action(test_action)
|
139
|
-
assert isinstance(task_id, str)
|
140
|
-
assert len(task_id) == 32
|
141
|
-
|
142
|
-
|
143
|
-
@pytest.mark.asyncio
|
144
|
-
async def test_get_task_status():
|
145
|
-
task_status = await client.get_task_status(test_action, await client.invoke_action(test_action))
|
146
|
-
assert isinstance(task_status, dict)
|
147
|
-
assert "currentStep" in task_status
|
148
|
-
assert "successful" in task_status.get("result")
|
149
|
-
|
150
|
-
|
151
|
-
async def _async_range(count: int):
|
152
|
-
for i in range(count):
|
153
|
-
yield str(i)
|
@@ -1,84 +0,0 @@
|
|
1
|
-
import asyncio
|
2
|
-
import os
|
3
|
-
from uuid import uuid4
|
4
|
-
|
5
|
-
import pytest
|
6
|
-
|
7
|
-
import anaplan_sdk
|
8
|
-
from anaplan_sdk.models import InsertionResult, ListMetadata, ModelStatus
|
9
|
-
|
10
|
-
client = anaplan_sdk.AsyncClient(
|
11
|
-
workspace_id=os.getenv("ANAPLAN_SDK_TEST_WORKSPACE_ID"),
|
12
|
-
model_id=os.getenv("ANAPLAN_SDK_TEST_MODEL_ID"),
|
13
|
-
certificate=os.getenv("ANAPLAN_SDK_TEST_CERT"),
|
14
|
-
private_key=os.getenv("ANAPLAN_SDK_TEST_PK"),
|
15
|
-
retry_count=3,
|
16
|
-
).transactional
|
17
|
-
|
18
|
-
|
19
|
-
@pytest.fixture(scope="module")
|
20
|
-
def event_loop():
|
21
|
-
yield asyncio.get_event_loop()
|
22
|
-
|
23
|
-
|
24
|
-
@pytest.mark.asyncio
|
25
|
-
async def test_list_workspaces():
|
26
|
-
modules = await client.list_modules()
|
27
|
-
assert isinstance(modules, list)
|
28
|
-
assert len(modules) > 0
|
29
|
-
|
30
|
-
|
31
|
-
@pytest.mark.asyncio
|
32
|
-
async def test_list_lists():
|
33
|
-
lists = await client.list_lists()
|
34
|
-
assert isinstance(lists, list)
|
35
|
-
assert len(lists) > 0
|
36
|
-
|
37
|
-
|
38
|
-
@pytest.mark.asyncio
|
39
|
-
async def test_list_line_items():
|
40
|
-
items = await client.list_line_items()
|
41
|
-
assert isinstance(items, list)
|
42
|
-
assert len(items) > 0
|
43
|
-
|
44
|
-
|
45
|
-
@pytest.mark.asyncio
|
46
|
-
async def test_get_list_items():
|
47
|
-
items = await client.get_list_items(101000000009)
|
48
|
-
assert isinstance(items, list)
|
49
|
-
|
50
|
-
|
51
|
-
@pytest.mark.asyncio
|
52
|
-
async def test_get_list_meta():
|
53
|
-
meta = await client.get_list_metadata(101000000009)
|
54
|
-
assert isinstance(meta, ListMetadata)
|
55
|
-
|
56
|
-
|
57
|
-
@pytest.mark.asyncio
|
58
|
-
async def test_get_model_status():
|
59
|
-
status = await client.get_model_status()
|
60
|
-
assert isinstance(status, ModelStatus)
|
61
|
-
|
62
|
-
|
63
|
-
@pytest.mark.asyncio
|
64
|
-
async def test_list_insertion():
|
65
|
-
result = await client.add_items_to_list(
|
66
|
-
101000000009, [{"code": str(uuid4()), "name": str(uuid4())}]
|
67
|
-
)
|
68
|
-
assert isinstance(result, InsertionResult)
|
69
|
-
assert result.failures == []
|
70
|
-
assert result.added == 1
|
71
|
-
assert result.ignored == 0
|
72
|
-
assert result.total == 1
|
73
|
-
|
74
|
-
|
75
|
-
@pytest.mark.asyncio
|
76
|
-
async def test_delete_list_items():
|
77
|
-
code = str(uuid4())
|
78
|
-
await client.add_items_to_list(101000000009, [{"code": code, "name": str(uuid4())}])
|
79
|
-
await client.delete_list_items(101000000009, [{"code": code}])
|
80
|
-
|
81
|
-
|
82
|
-
@pytest.mark.asyncio
|
83
|
-
async def test_reset_list_index():
|
84
|
-
await client.reset_list_index(101000000010)
|
@@ -1,65 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
from uuid import uuid4
|
3
|
-
|
4
|
-
import anaplan_sdk
|
5
|
-
from anaplan_sdk.models import InsertionResult, ListMetadata, ModelStatus
|
6
|
-
|
7
|
-
client = anaplan_sdk.Client(
|
8
|
-
workspace_id=os.getenv("ANAPLAN_SDK_TEST_WORKSPACE_ID"),
|
9
|
-
model_id=os.getenv("ANAPLAN_SDK_TEST_MODEL_ID"),
|
10
|
-
certificate=os.getenv("ANAPLAN_SDK_TEST_CERT"),
|
11
|
-
private_key=os.getenv("ANAPLAN_SDK_TEST_PK"),
|
12
|
-
retry_count=3,
|
13
|
-
).transactional
|
14
|
-
|
15
|
-
|
16
|
-
def test_list_workspaces():
|
17
|
-
modules = client.list_modules()
|
18
|
-
assert isinstance(modules, list)
|
19
|
-
assert len(modules) > 0
|
20
|
-
|
21
|
-
|
22
|
-
def test_list_lists():
|
23
|
-
lists = client.list_lists()
|
24
|
-
assert isinstance(lists, list)
|
25
|
-
assert len(lists) > 0
|
26
|
-
|
27
|
-
|
28
|
-
def test_list_line_items():
|
29
|
-
items = client.list_line_items()
|
30
|
-
assert isinstance(items, list)
|
31
|
-
assert len(items) > 0
|
32
|
-
|
33
|
-
|
34
|
-
def test_get_list_items():
|
35
|
-
items = client.get_list_items(101000000009)
|
36
|
-
assert isinstance(items, list)
|
37
|
-
|
38
|
-
|
39
|
-
def test_get_list_meta():
|
40
|
-
meta = client.get_list_metadata(101000000009)
|
41
|
-
assert isinstance(meta, ListMetadata)
|
42
|
-
|
43
|
-
|
44
|
-
def test_get_model_status():
|
45
|
-
status = client.get_model_status()
|
46
|
-
assert isinstance(status, ModelStatus)
|
47
|
-
|
48
|
-
|
49
|
-
def test_list_insertion():
|
50
|
-
result = client.add_items_to_list(101000000009, [{"code": str(uuid4()), "name": str(uuid4())}])
|
51
|
-
assert isinstance(result, InsertionResult)
|
52
|
-
assert result.failures == []
|
53
|
-
assert result.added == 1
|
54
|
-
assert result.ignored == 0
|
55
|
-
assert result.total == 1
|
56
|
-
|
57
|
-
|
58
|
-
def test_delete_list_items():
|
59
|
-
code = str(uuid4())
|
60
|
-
client.add_items_to_list(101000000009, [{"code": code, "name": str(uuid4())}])
|
61
|
-
client.delete_list_items(101000000009, [{"code": code}])
|
62
|
-
|
63
|
-
|
64
|
-
def test_reset_list_index():
|
65
|
-
client.reset_list_index(101000000010)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|