magic-campus-cli 0.1.0__tar.gz → 0.1.1__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.
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/PKG-INFO +47 -5
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/README.md +46 -4
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magic_campus_cli.egg-info/PKG-INFO +47 -5
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magic_campus_cli.egg-info/SOURCES.txt +4 -0
- magic_campus_cli-0.1.1/magiccampus_cli/__init__.py +1 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/cli.py +5 -1
- magic_campus_cli-0.1.1/magiccampus_cli/commands/assistant.py +23 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/__init__.py +3 -1
- magic_campus_cli-0.1.1/magiccampus_sdk/assistant_api.py +48 -0
- magic_campus_cli-0.1.1/magiccampus_sdk/assistant_client.py +24 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/platform_client.py +8 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/pyproject.toml +1 -1
- magic_campus_cli-0.1.1/tests/test_assistant_user_id.py +170 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_auth_status.py +1 -1
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_cli_config.py +2 -2
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_cli_domains.py +4 -4
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_cli_group.py +10 -10
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_cli_interactive.py +2 -2
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_cli_notify.py +15 -15
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_cli_update.py +0 -31
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_growth_profile.py +1 -1
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_growth_profile_init.py +2 -2
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_notice_list.py +2 -2
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_smoke_cli.py +10 -2
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_user_academy.py +1 -1
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_user_elements.py +1 -1
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_user_list.py +4 -4
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_user_profile.py +2 -2
- magic_campus_cli-0.1.0/magiccampus_cli/__init__.py +0 -1
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/MANIFEST.in +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magic_campus_cli.egg-info/dependency_links.txt +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magic_campus_cli.egg-info/entry_points.txt +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magic_campus_cli.egg-info/requires.txt +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magic_campus_cli.egg-info/top_level.txt +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/__main__.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/accounts.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/client.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/commands/auth.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/commands/comment.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/commands/config.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/commands/feed.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/commands/group.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/commands/im.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/commands/notify.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/commands/playgroup.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/commands/reaction.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/commands/space.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/commands/user.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/config_store.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/notify.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/output.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/prompts.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/targets.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/update.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_cli/utils.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/auth.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/comment_client.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/feed_api.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/feed_client.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/group_api.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/group_client.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/http/__init__.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/http/group_info_api.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/http/http_api.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/http/http_send.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/http/media.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/http/models.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/http/self_user_info_api.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/http/text.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/models.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/platform_http.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/playgroup_api.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/playgroup_client.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/reaction_api.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/space_api.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/space_client.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/user_client.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/magiccampus_sdk/user_info_api.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/scripts/smoke_cli.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/setup.cfg +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_auth.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_cli_group_get.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_cli_main.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_comments.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_environment_auth.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_feed_list.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_http_operations.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_message_reaction.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_playgroup_participation.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_playgroups.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_user_ext.py +0 -0
- {magic_campus_cli-0.1.0 → magic_campus_cli-0.1.1}/tests/test_user_info_update.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: magic-campus-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Magic Campus business HTTP SDK and CLI
|
|
5
5
|
License-Expression: AGPL-3.0-or-later
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -17,15 +17,45 @@ Business Python SDK and HTTP-only `magic-campus` command. Install this distribut
|
|
|
17
17
|
in a dedicated tool environment. It provides `magiccampus_sdk` and
|
|
18
18
|
`magiccampus_cli`; do not co-install it with the frozen `magic-campus-sdk`.
|
|
19
19
|
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
python -m pip install magic-campus-cli
|
|
24
|
+
export MAGIC_CAMPUS_BASE_URL="<api-base-url>"
|
|
25
|
+
export MAGIC_CAMPUS_API_KEY='<api-key>'
|
|
26
|
+
magic-campus --help
|
|
27
|
+
magic-campus user get --id 10001 --format json
|
|
28
|
+
magic-campus assistant user-id --user-id 123 --format json
|
|
29
|
+
magic-campus playgroup list --format json
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`MAGIC_CAMPUS_BASE_URL` and `MAGIC_CAMPUS_API_KEY` select the business environment
|
|
33
|
+
and credential. New installs and updates of this package do not install the IM
|
|
34
|
+
distribution. Current-conversation replies remain the responsibility of the
|
|
35
|
+
Agent's Channel.
|
|
36
|
+
|
|
20
37
|
```python
|
|
38
|
+
import os
|
|
39
|
+
|
|
21
40
|
from magiccampus_sdk import MagicCampusClient, MagicCampusClientConfig
|
|
22
41
|
|
|
23
|
-
client = MagicCampusClient(MagicCampusClientConfig(
|
|
24
|
-
|
|
42
|
+
client = MagicCampusClient(MagicCampusClientConfig(
|
|
43
|
+
apiurl=os.environ["MAGIC_CAMPUS_BASE_URL"],
|
|
44
|
+
apikey=os.environ["MAGIC_CAMPUS_API_KEY"],
|
|
45
|
+
))
|
|
46
|
+
# client.user, client.feed, client.space, client.playgroup, client.comment, client.assistant
|
|
25
47
|
# client.group: HTTP group management, members, and message queries
|
|
26
48
|
# client.im.http(): HTTP message sender; client.im also supplies reactions
|
|
27
49
|
```
|
|
28
50
|
|
|
51
|
+
`client.assistant.get_user_id(123)` calls `GET /api/v1/assistant/userId?userId=123`
|
|
52
|
+
and returns an integer assistant user ID or `None`. The CLI returns
|
|
53
|
+
`{"ok": true, "userId": 123, "assistantUserId": 456}` (plus `_meta`), or
|
|
54
|
+
`assistantUserId: null` when no identity is bound, including nonexistent owners.
|
|
55
|
+
The explicit target must be a positive Long integer and is never replaced by
|
|
56
|
+
the API Key's owner. This read does not create or wake an assistant, and a
|
|
57
|
+
returned ID does not prove readiness or grant access to the assistant's profile.
|
|
58
|
+
|
|
29
59
|
All commands use HTTP. Existing OpenIM HTTP group operations retain their request
|
|
30
60
|
semantics; no command initializes a websocket. `im group kick --group ID --users
|
|
31
61
|
ID1,ID2` uses the business kick endpoint. Group invitations and member queries use
|
|
@@ -47,5 +77,17 @@ is installed. This is an update guard, not a pip installation conflict mechanism
|
|
|
47
77
|
manual co-installation can still overwrite shared files and is unsupported.
|
|
48
78
|
The legacy updater continues to target the frozen package name.
|
|
49
79
|
|
|
50
|
-
|
|
51
|
-
|
|
80
|
+
## Development and validation
|
|
81
|
+
|
|
82
|
+
From the repository root:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
uv sync --frozen --all-packages
|
|
86
|
+
uv run --frozen --no-sync pytest -q magic-campus-cli/tests
|
|
87
|
+
uv build --no-sources --package magic-campus-cli --out-dir dist/cli --clear
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Use `uv sync --frozen --package magic-campus-cli --group dev` for an environment containing
|
|
91
|
+
only this member and development tools. See [workspace instructions](../README.md)
|
|
92
|
+
and [build/install checks](../PYPI_RELEASE.md). This source does not perform an
|
|
93
|
+
online Agent upgrade.
|
|
@@ -4,15 +4,45 @@ Business Python SDK and HTTP-only `magic-campus` command. Install this distribut
|
|
|
4
4
|
in a dedicated tool environment. It provides `magiccampus_sdk` and
|
|
5
5
|
`magiccampus_cli`; do not co-install it with the frozen `magic-campus-sdk`.
|
|
6
6
|
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
python -m pip install magic-campus-cli
|
|
11
|
+
export MAGIC_CAMPUS_BASE_URL="<api-base-url>"
|
|
12
|
+
export MAGIC_CAMPUS_API_KEY='<api-key>'
|
|
13
|
+
magic-campus --help
|
|
14
|
+
magic-campus user get --id 10001 --format json
|
|
15
|
+
magic-campus assistant user-id --user-id 123 --format json
|
|
16
|
+
magic-campus playgroup list --format json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`MAGIC_CAMPUS_BASE_URL` and `MAGIC_CAMPUS_API_KEY` select the business environment
|
|
20
|
+
and credential. New installs and updates of this package do not install the IM
|
|
21
|
+
distribution. Current-conversation replies remain the responsibility of the
|
|
22
|
+
Agent's Channel.
|
|
23
|
+
|
|
7
24
|
```python
|
|
25
|
+
import os
|
|
26
|
+
|
|
8
27
|
from magiccampus_sdk import MagicCampusClient, MagicCampusClientConfig
|
|
9
28
|
|
|
10
|
-
client = MagicCampusClient(MagicCampusClientConfig(
|
|
11
|
-
|
|
29
|
+
client = MagicCampusClient(MagicCampusClientConfig(
|
|
30
|
+
apiurl=os.environ["MAGIC_CAMPUS_BASE_URL"],
|
|
31
|
+
apikey=os.environ["MAGIC_CAMPUS_API_KEY"],
|
|
32
|
+
))
|
|
33
|
+
# client.user, client.feed, client.space, client.playgroup, client.comment, client.assistant
|
|
12
34
|
# client.group: HTTP group management, members, and message queries
|
|
13
35
|
# client.im.http(): HTTP message sender; client.im also supplies reactions
|
|
14
36
|
```
|
|
15
37
|
|
|
38
|
+
`client.assistant.get_user_id(123)` calls `GET /api/v1/assistant/userId?userId=123`
|
|
39
|
+
and returns an integer assistant user ID or `None`. The CLI returns
|
|
40
|
+
`{"ok": true, "userId": 123, "assistantUserId": 456}` (plus `_meta`), or
|
|
41
|
+
`assistantUserId: null` when no identity is bound, including nonexistent owners.
|
|
42
|
+
The explicit target must be a positive Long integer and is never replaced by
|
|
43
|
+
the API Key's owner. This read does not create or wake an assistant, and a
|
|
44
|
+
returned ID does not prove readiness or grant access to the assistant's profile.
|
|
45
|
+
|
|
16
46
|
All commands use HTTP. Existing OpenIM HTTP group operations retain their request
|
|
17
47
|
semantics; no command initializes a websocket. `im group kick --group ID --users
|
|
18
48
|
ID1,ID2` uses the business kick endpoint. Group invitations and member queries use
|
|
@@ -34,5 +64,17 @@ is installed. This is an update guard, not a pip installation conflict mechanism
|
|
|
34
64
|
manual co-installation can still overwrite shared files and is unsupported.
|
|
35
65
|
The legacy updater continues to target the frozen package name.
|
|
36
66
|
|
|
37
|
-
|
|
38
|
-
|
|
67
|
+
## Development and validation
|
|
68
|
+
|
|
69
|
+
From the repository root:
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
uv sync --frozen --all-packages
|
|
73
|
+
uv run --frozen --no-sync pytest -q magic-campus-cli/tests
|
|
74
|
+
uv build --no-sources --package magic-campus-cli --out-dir dist/cli --clear
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Use `uv sync --frozen --package magic-campus-cli --group dev` for an environment containing
|
|
78
|
+
only this member and development tools. See [workspace instructions](../README.md)
|
|
79
|
+
and [build/install checks](../PYPI_RELEASE.md). This source does not perform an
|
|
80
|
+
online Agent upgrade.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: magic-campus-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Magic Campus business HTTP SDK and CLI
|
|
5
5
|
License-Expression: AGPL-3.0-or-later
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -17,15 +17,45 @@ Business Python SDK and HTTP-only `magic-campus` command. Install this distribut
|
|
|
17
17
|
in a dedicated tool environment. It provides `magiccampus_sdk` and
|
|
18
18
|
`magiccampus_cli`; do not co-install it with the frozen `magic-campus-sdk`.
|
|
19
19
|
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
python -m pip install magic-campus-cli
|
|
24
|
+
export MAGIC_CAMPUS_BASE_URL="<api-base-url>"
|
|
25
|
+
export MAGIC_CAMPUS_API_KEY='<api-key>'
|
|
26
|
+
magic-campus --help
|
|
27
|
+
magic-campus user get --id 10001 --format json
|
|
28
|
+
magic-campus assistant user-id --user-id 123 --format json
|
|
29
|
+
magic-campus playgroup list --format json
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`MAGIC_CAMPUS_BASE_URL` and `MAGIC_CAMPUS_API_KEY` select the business environment
|
|
33
|
+
and credential. New installs and updates of this package do not install the IM
|
|
34
|
+
distribution. Current-conversation replies remain the responsibility of the
|
|
35
|
+
Agent's Channel.
|
|
36
|
+
|
|
20
37
|
```python
|
|
38
|
+
import os
|
|
39
|
+
|
|
21
40
|
from magiccampus_sdk import MagicCampusClient, MagicCampusClientConfig
|
|
22
41
|
|
|
23
|
-
client = MagicCampusClient(MagicCampusClientConfig(
|
|
24
|
-
|
|
42
|
+
client = MagicCampusClient(MagicCampusClientConfig(
|
|
43
|
+
apiurl=os.environ["MAGIC_CAMPUS_BASE_URL"],
|
|
44
|
+
apikey=os.environ["MAGIC_CAMPUS_API_KEY"],
|
|
45
|
+
))
|
|
46
|
+
# client.user, client.feed, client.space, client.playgroup, client.comment, client.assistant
|
|
25
47
|
# client.group: HTTP group management, members, and message queries
|
|
26
48
|
# client.im.http(): HTTP message sender; client.im also supplies reactions
|
|
27
49
|
```
|
|
28
50
|
|
|
51
|
+
`client.assistant.get_user_id(123)` calls `GET /api/v1/assistant/userId?userId=123`
|
|
52
|
+
and returns an integer assistant user ID or `None`. The CLI returns
|
|
53
|
+
`{"ok": true, "userId": 123, "assistantUserId": 456}` (plus `_meta`), or
|
|
54
|
+
`assistantUserId: null` when no identity is bound, including nonexistent owners.
|
|
55
|
+
The explicit target must be a positive Long integer and is never replaced by
|
|
56
|
+
the API Key's owner. This read does not create or wake an assistant, and a
|
|
57
|
+
returned ID does not prove readiness or grant access to the assistant's profile.
|
|
58
|
+
|
|
29
59
|
All commands use HTTP. Existing OpenIM HTTP group operations retain their request
|
|
30
60
|
semantics; no command initializes a websocket. `im group kick --group ID --users
|
|
31
61
|
ID1,ID2` uses the business kick endpoint. Group invitations and member queries use
|
|
@@ -47,5 +77,17 @@ is installed. This is an update guard, not a pip installation conflict mechanism
|
|
|
47
77
|
manual co-installation can still overwrite shared files and is unsupported.
|
|
48
78
|
The legacy updater continues to target the frozen package name.
|
|
49
79
|
|
|
50
|
-
|
|
51
|
-
|
|
80
|
+
## Development and validation
|
|
81
|
+
|
|
82
|
+
From the repository root:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
uv sync --frozen --all-packages
|
|
86
|
+
uv run --frozen --no-sync pytest -q magic-campus-cli/tests
|
|
87
|
+
uv build --no-sources --package magic-campus-cli --out-dir dist/cli --clear
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Use `uv sync --frozen --package magic-campus-cli --group dev` for an environment containing
|
|
91
|
+
only this member and development tools. See [workspace instructions](../README.md)
|
|
92
|
+
and [build/install checks](../PYPI_RELEASE.md). This source does not perform an
|
|
93
|
+
online Agent upgrade.
|
|
@@ -19,6 +19,7 @@ magiccampus_cli/prompts.py
|
|
|
19
19
|
magiccampus_cli/targets.py
|
|
20
20
|
magiccampus_cli/update.py
|
|
21
21
|
magiccampus_cli/utils.py
|
|
22
|
+
magiccampus_cli/commands/assistant.py
|
|
22
23
|
magiccampus_cli/commands/auth.py
|
|
23
24
|
magiccampus_cli/commands/comment.py
|
|
24
25
|
magiccampus_cli/commands/config.py
|
|
@@ -31,6 +32,8 @@ magiccampus_cli/commands/reaction.py
|
|
|
31
32
|
magiccampus_cli/commands/space.py
|
|
32
33
|
magiccampus_cli/commands/user.py
|
|
33
34
|
magiccampus_sdk/__init__.py
|
|
35
|
+
magiccampus_sdk/assistant_api.py
|
|
36
|
+
magiccampus_sdk/assistant_client.py
|
|
34
37
|
magiccampus_sdk/auth.py
|
|
35
38
|
magiccampus_sdk/comment_client.py
|
|
36
39
|
magiccampus_sdk/feed_api.py
|
|
@@ -56,6 +59,7 @@ magiccampus_sdk/http/models.py
|
|
|
56
59
|
magiccampus_sdk/http/self_user_info_api.py
|
|
57
60
|
magiccampus_sdk/http/text.py
|
|
58
61
|
scripts/smoke_cli.py
|
|
62
|
+
tests/test_assistant_user_id.py
|
|
59
63
|
tests/test_auth.py
|
|
60
64
|
tests/test_auth_status.py
|
|
61
65
|
tests/test_cli_config.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.1"
|
|
@@ -4,6 +4,7 @@ import os
|
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
6
|
from . import __version__
|
|
7
|
+
from .commands.assistant import run_assistant_command
|
|
7
8
|
from .commands.auth import run_auth_command
|
|
8
9
|
from .commands.config import run_config_command
|
|
9
10
|
from .commands.comment import run_comment_command
|
|
@@ -90,6 +91,7 @@ def usage() -> str:
|
|
|
90
91
|
" space create-notice --space <spaceId> --title <title> --text <text> --expiretime <timestamp> [--account default]",
|
|
91
92
|
" space group update-name --group <groupId> --name <name> [--account default]",
|
|
92
93
|
" user get --id <userId> [--account default]",
|
|
94
|
+
" assistant user-id --user-id <ownerUserId> [--account default]",
|
|
93
95
|
" user list (--all | --random) [--fields <field1,field2>] [--academy-code <code>] [--account default]",
|
|
94
96
|
" user update-info [--nickname <name>] [--avatar-url <url>] [--introduction <text>] [--birth <yyyy-MM-dd>] [--gender <MALE|FEMALE|OTHER|UNKNOWN>] [--tags <json-array>] [--account default] (authenticated user; no --id)",
|
|
95
97
|
" user update-info (--json <object> | --body <path|->) [--account default]",
|
|
@@ -135,7 +137,7 @@ def main(raw_argv: list[str] | None = None) -> int:
|
|
|
135
137
|
|
|
136
138
|
if args[0] == "update" and len(args) != 1:
|
|
137
139
|
raise RuntimeError("update does not accept arguments.")
|
|
138
|
-
if args[0] in {"update", "auth", "im", "user", "space", "playgroup", "feed", "comment", "notify"}:
|
|
140
|
+
if args[0] in {"update", "auth", "im", "user", "assistant", "space", "playgroup", "feed", "comment", "notify"}:
|
|
139
141
|
exit_code = ensure_latest(argv, refresh=args[0] == "update")
|
|
140
142
|
if exit_code is not None:
|
|
141
143
|
return exit_code
|
|
@@ -150,6 +152,8 @@ def main(raw_argv: list[str] | None = None) -> int:
|
|
|
150
152
|
result = run_im_command(args[1] if len(args) > 1 else None, args[2:], parse_options)
|
|
151
153
|
elif args[0] == "user":
|
|
152
154
|
result = run_user_command(args[1] if len(args) > 1 else None, args[2:], parse_options)
|
|
155
|
+
elif args[0] == "assistant":
|
|
156
|
+
result = run_assistant_command(args[1] if len(args) > 1 else None, args[2:], parse_options)
|
|
153
157
|
elif args[0] == "playgroup":
|
|
154
158
|
result = run_playgroup_command(args[1] if len(args) > 1 else None, args[2:], parse_options)
|
|
155
159
|
elif args[0] == "space":
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from magiccampus_sdk import MagicCampusClient, MagicCampusClientConfig
|
|
4
|
+
from magiccampus_sdk.assistant_api import normalize_owner_user_id
|
|
5
|
+
|
|
6
|
+
from ..config_store import read_config_root
|
|
7
|
+
from .auth import resolve_account_or_throw
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def run_assistant_command(subcommand: str | None, argv: list[str], parse_options):
|
|
11
|
+
if subcommand != "user-id":
|
|
12
|
+
raise RuntimeError(f"Unknown assistant subcommand: {subcommand}")
|
|
13
|
+
options, positionals = parse_options(argv)
|
|
14
|
+
if positionals or set(options) - {"user-id", "account"}:
|
|
15
|
+
raise RuntimeError("assistant user-id accepts only --user-id and --account.")
|
|
16
|
+
if "user-id" not in options or options["user-id"] is True:
|
|
17
|
+
raise RuntimeError("assistant user-id requires --user-id <ownerUserId>.")
|
|
18
|
+
user_id = normalize_owner_user_id(options["user-id"])
|
|
19
|
+
account = resolve_account_or_throw(read_config_root(), options.get("account"))
|
|
20
|
+
client = MagicCampusClient(MagicCampusClientConfig(
|
|
21
|
+
apiurl=account.apiurl, apikey=account.apikey, platform=account.platform,
|
|
22
|
+
))
|
|
23
|
+
return {"ok": True, "userId": user_id, "assistantUserId": client.assistant.get_user_id(user_id)}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from importlib import import_module
|
|
2
2
|
|
|
3
|
-
__version__ = "0.1.
|
|
3
|
+
__version__ = "0.1.1"
|
|
4
4
|
_EXPORTS = {
|
|
5
|
+
"MagicCampusAssistantClient": ("magiccampus_sdk.assistant_client", "MagicCampusAssistantClient"),
|
|
6
|
+
"MagicCampusAssistantClientConfig": ("magiccampus_sdk.assistant_client", "MagicCampusAssistantClientConfig"),
|
|
5
7
|
"MagicCampusCommentClient": ("magiccampus_sdk.comment_client", "MagicCampusCommentClient"),
|
|
6
8
|
"MagicCampusCommentClientConfig": ("magiccampus_sdk.comment_client", "MagicCampusCommentClientConfig"),
|
|
7
9
|
"MagicCampusAPIHTTPError": ("magiccampus_sdk.platform_http", "MagicCampusAPIHTTPError"),
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from .auth import normalize_apiurl
|
|
8
|
+
from .platform_http import MagicCampusAPIHTTPError, MagicCampusAPIRemoteError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def normalize_owner_user_id(user_id: str | int) -> int:
|
|
12
|
+
if isinstance(user_id, bool) or not isinstance(user_id, (str, int)):
|
|
13
|
+
raise ValueError("user_id must be a positive Long integer")
|
|
14
|
+
text = str(user_id).strip()
|
|
15
|
+
if not re.fullmatch(r"[0-9]{1,19}", text) or not 0 < int(text) <= 2**63 - 1:
|
|
16
|
+
raise ValueError("user_id must be a positive Long integer")
|
|
17
|
+
return int(text)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def fetch_assistant_user_id(
|
|
21
|
+
*, apiurl: str, apikey: str, user_id: str | int, timeout_seconds: float = 15.0,
|
|
22
|
+
) -> int | None:
|
|
23
|
+
"""Look up the explicit owner's persisted assistant ID without waking the assistant."""
|
|
24
|
+
owner_id = normalize_owner_user_id(user_id)
|
|
25
|
+
base = normalize_apiurl(apiurl)
|
|
26
|
+
token = str(apikey or "").strip()
|
|
27
|
+
if not token:
|
|
28
|
+
raise ValueError("magiccampus apikey is required")
|
|
29
|
+
response = httpx.get(
|
|
30
|
+
f"{base}/api/v1/assistant/userId", params={"userId": owner_id},
|
|
31
|
+
headers={"Authorization": f"Bearer {token}"}, timeout=timeout_seconds,
|
|
32
|
+
)
|
|
33
|
+
try:
|
|
34
|
+
response.raise_for_status()
|
|
35
|
+
except httpx.HTTPStatusError as exc:
|
|
36
|
+
raise MagicCampusAPIHTTPError(exc.response.status_code, exc.response.text) from exc
|
|
37
|
+
payload = response.json()
|
|
38
|
+
if not isinstance(payload, dict) or type(payload.get("code")) is not int:
|
|
39
|
+
raise ValueError("magiccampus assistant response must have an integer code")
|
|
40
|
+
if payload["code"] != 200:
|
|
41
|
+
raise MagicCampusAPIRemoteError(
|
|
42
|
+
payload["code"], str(payload.get("msg") or ""), str(payload.get("detail") or ""),
|
|
43
|
+
)
|
|
44
|
+
# The server may omit null fields when no assistant identity is bound.
|
|
45
|
+
data = payload.get("data")
|
|
46
|
+
if data is not None and (type(data) is not int or not 0 < data <= 2**63 - 1):
|
|
47
|
+
raise ValueError("magiccampus assistant response data must be a positive Long integer or null")
|
|
48
|
+
return data
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
from .assistant_api import fetch_assistant_user_id
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True)
|
|
9
|
+
class MagicCampusAssistantClientConfig:
|
|
10
|
+
apiurl: str
|
|
11
|
+
apikey: str
|
|
12
|
+
request_timeout_seconds: float = 15.0
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class MagicCampusAssistantClient:
|
|
16
|
+
def __init__(self, config: MagicCampusAssistantClientConfig) -> None:
|
|
17
|
+
self._config = config
|
|
18
|
+
|
|
19
|
+
def get_user_id(self, user_id: str | int) -> int | None:
|
|
20
|
+
"""Return the explicit owner's assistant user ID, or None when unbound."""
|
|
21
|
+
return fetch_assistant_user_id(
|
|
22
|
+
apiurl=self._config.apiurl, apikey=self._config.apikey, user_id=user_id,
|
|
23
|
+
timeout_seconds=self._config.request_timeout_seconds,
|
|
24
|
+
)
|
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
from typing import TYPE_CHECKING, Any
|
|
5
5
|
|
|
6
|
+
from .assistant_client import MagicCampusAssistantClient, MagicCampusAssistantClientConfig
|
|
6
7
|
from .comment_client import MagicCampusCommentClient, MagicCampusCommentClientConfig
|
|
7
8
|
from .feed_client import MagicCampusFeedClient, MagicCampusFeedClientConfig
|
|
8
9
|
from .reaction_api import add_message_reaction, delete_message_reaction
|
|
@@ -114,6 +115,13 @@ class MagicCampusIMClient:
|
|
|
114
115
|
class MagicCampusClient:
|
|
115
116
|
def __init__(self, config: MagicCampusClientConfig) -> None:
|
|
116
117
|
self.config = config
|
|
118
|
+
self.assistant = MagicCampusAssistantClient(
|
|
119
|
+
MagicCampusAssistantClientConfig(
|
|
120
|
+
apiurl=config.apiurl,
|
|
121
|
+
apikey=config.apikey,
|
|
122
|
+
request_timeout_seconds=config.request_timeout_seconds,
|
|
123
|
+
)
|
|
124
|
+
)
|
|
117
125
|
self.im = MagicCampusIMClient(config)
|
|
118
126
|
from .group_client import MagicCampusGroupClient
|
|
119
127
|
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
import httpx
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from magiccampus_cli.cli import main
|
|
7
|
+
from magiccampus_sdk import MagicCampusClient, MagicCampusClientConfig
|
|
8
|
+
from magiccampus_sdk import assistant_api
|
|
9
|
+
from magiccampus_sdk.platform_http import MagicCampusAPIHTTPError, MagicCampusAPIRemoteError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@pytest.fixture
|
|
13
|
+
def api(monkeypatch):
|
|
14
|
+
calls = []
|
|
15
|
+
reply = {"code": 200, "msg": "success", "data": 456}
|
|
16
|
+
|
|
17
|
+
def get(url, **kwargs):
|
|
18
|
+
calls.append({"url": url, **kwargs})
|
|
19
|
+
return httpx.Response(200, json=reply, request=httpx.Request("GET", url))
|
|
20
|
+
|
|
21
|
+
monkeypatch.setattr(assistant_api.httpx, "get", get)
|
|
22
|
+
return calls, reply
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@pytest.fixture
|
|
26
|
+
def client():
|
|
27
|
+
return MagicCampusClient(MagicCampusClientConfig(
|
|
28
|
+
apiurl="https://campus.example.com/", apikey=" example-key ", request_timeout_seconds=7.5,
|
|
29
|
+
))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_sdk_queries_explicit_owner_without_identity_exchange(client, api):
|
|
33
|
+
calls, _ = api
|
|
34
|
+
assert client.assistant.get_user_id(" 123 ") == 456
|
|
35
|
+
assert calls == [{
|
|
36
|
+
"url": "https://campus.example.com/api/v1/assistant/userId", "params": {"userId": 123},
|
|
37
|
+
"headers": {"Authorization": "Bearer example-key"}, "timeout": 7.5,
|
|
38
|
+
}]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@pytest.mark.parametrize("missing_data", [False, True])
|
|
42
|
+
def test_unbound_or_missing_owner_is_successful_none(client, api, missing_data):
|
|
43
|
+
calls, reply = api
|
|
44
|
+
reply["data"] = None
|
|
45
|
+
if missing_data:
|
|
46
|
+
reply.pop("data")
|
|
47
|
+
assert client.assistant.get_user_id(123) is None
|
|
48
|
+
assert len(calls) == 1
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@pytest.mark.parametrize("user_id", [None, True, False, "", " ", "abc", "1.5", 1.5, [], 0, -1, 2**63])
|
|
52
|
+
def test_invalid_owner_fails_before_network(client, api, user_id):
|
|
53
|
+
with pytest.raises(ValueError, match="user_id"):
|
|
54
|
+
client.assistant.get_user_id(user_id)
|
|
55
|
+
assert not api[0]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_long_ids_keep_integer_precision(client, api):
|
|
59
|
+
api[1]["data"] = 2**63 - 2
|
|
60
|
+
assert client.assistant.get_user_id(str(2**63 - 1)) == 2**63 - 2
|
|
61
|
+
assert api[0][0]["params"] == {"userId": 2**63 - 1}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@pytest.mark.parametrize("field", ["apiurl", "apikey"])
|
|
65
|
+
def test_missing_configuration_does_not_connect(api, field):
|
|
66
|
+
config = {"apiurl": "https://campus.example.com", "apikey": "key", field: " "}
|
|
67
|
+
with pytest.raises(ValueError, match=f"{field} is required"):
|
|
68
|
+
MagicCampusClient(MagicCampusClientConfig(**config)).assistant.get_user_id(123)
|
|
69
|
+
assert not api[0]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@pytest.mark.parametrize("code", [400, 401, 403, 404, 500])
|
|
73
|
+
def test_business_failure_is_preserved_not_returned_as_unbound(client, api, code):
|
|
74
|
+
calls, reply = api
|
|
75
|
+
reply.update(code=code, msg="denied", detail="example detail", data=None)
|
|
76
|
+
with pytest.raises(MagicCampusAPIRemoteError) as error:
|
|
77
|
+
client.assistant.get_user_id(123)
|
|
78
|
+
assert (error.value.code, error.value.message, error.value.detail) == (code, "denied", "example detail")
|
|
79
|
+
assert len(calls) == 1
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@pytest.mark.parametrize("status", [401, 403, 404, 500])
|
|
83
|
+
def test_http_failure_is_preserved(client, monkeypatch, status):
|
|
84
|
+
calls = []
|
|
85
|
+
|
|
86
|
+
def get(url, **kwargs):
|
|
87
|
+
calls.append(url)
|
|
88
|
+
return httpx.Response(status, text="failure", request=httpx.Request("GET", url))
|
|
89
|
+
|
|
90
|
+
monkeypatch.setattr(assistant_api.httpx, "get", get)
|
|
91
|
+
with pytest.raises(MagicCampusAPIHTTPError) as error:
|
|
92
|
+
client.assistant.get_user_id(123)
|
|
93
|
+
assert (error.value.status_code, error.value.body) == (status, "failure")
|
|
94
|
+
assert calls == ["https://campus.example.com/api/v1/assistant/userId"]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@pytest.mark.parametrize("payload", [[], {}, {"code": "200"}, {"code": True},
|
|
98
|
+
*({"code": 200, "data": value} for value in [True, "456", 1.5, {}, [], 0, -1, 2**63]),
|
|
99
|
+
])
|
|
100
|
+
def test_malformed_reply_is_rejected(client, monkeypatch, payload):
|
|
101
|
+
monkeypatch.setattr(assistant_api.httpx, "get", lambda url, **kwargs: httpx.Response(
|
|
102
|
+
200, json=payload, request=httpx.Request("GET", url),
|
|
103
|
+
))
|
|
104
|
+
with pytest.raises(ValueError):
|
|
105
|
+
client.assistant.get_user_id(123)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@pytest.fixture
|
|
109
|
+
def cli_environment(monkeypatch, tmp_path):
|
|
110
|
+
monkeypatch.setenv("MAGIC_CAMPUS_BASE_URL", "https://campus.example.com")
|
|
111
|
+
monkeypatch.setenv("MAGIC_CAMPUS_API_KEY", "cli-key")
|
|
112
|
+
monkeypatch.setenv("MAGIC_CAMPUS_HOME", str(tmp_path))
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@pytest.mark.parametrize("data", [456, None])
|
|
116
|
+
@pytest.mark.parametrize("output_format", ["json", "pretty", "table", "ndjson"])
|
|
117
|
+
def test_cli_success_and_null_in_all_formats(cli_environment, api, capsys, data, output_format):
|
|
118
|
+
calls, reply = api
|
|
119
|
+
reply["data"] = data
|
|
120
|
+
assert main(["assistant", "user-id", "--user-id", "123", "--format", output_format]) == 0
|
|
121
|
+
output = capsys.readouterr().out
|
|
122
|
+
if output_format in {"json", "ndjson"}:
|
|
123
|
+
payload = json.loads(output if output_format == "json" else output.splitlines()[-1])
|
|
124
|
+
assert payload["ok"] is True
|
|
125
|
+
assert payload["userId"] == 123
|
|
126
|
+
assert payload["assistantUserId"] == data
|
|
127
|
+
else:
|
|
128
|
+
assert "assistantUserId" in output
|
|
129
|
+
assert calls[0]["headers"] == {"Authorization": "Bearer cli-key"}
|
|
130
|
+
assert calls[0]["params"] == {"userId": 123}
|
|
131
|
+
assert len(calls) == 1
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@pytest.mark.parametrize("args", [[], ["user-id"], ["user-id", "--user-id"],
|
|
135
|
+
["user-id", "--user-id", "0"], ["user-id", "--user-id", "abc"],
|
|
136
|
+
["user-id", "--user-id", "123", "--id", "456"], ["other"],
|
|
137
|
+
["user-id", "123"],
|
|
138
|
+
])
|
|
139
|
+
def test_cli_invalid_arguments_do_not_connect(cli_environment, api, capsys, args):
|
|
140
|
+
assert main(["assistant", *args]) == 1
|
|
141
|
+
assert json.loads(capsys.readouterr().out)["ok"] is False
|
|
142
|
+
assert not api[0]
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def test_cli_missing_credentials_do_not_connect(cli_environment, api, capsys, monkeypatch):
|
|
146
|
+
monkeypatch.delenv("MAGIC_CAMPUS_API_KEY")
|
|
147
|
+
assert main(["assistant", "user-id", "--user-id", "123"]) == 1
|
|
148
|
+
assert json.loads(capsys.readouterr().out)["ok"] is False
|
|
149
|
+
assert not api[0]
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def test_cli_business_failure_is_an_error(cli_environment, api, capsys):
|
|
153
|
+
api[1].update(code=401, msg="invalid binding", data=None)
|
|
154
|
+
assert main(["assistant", "user-id", "--user-id", "123"]) == 1
|
|
155
|
+
payload = json.loads(capsys.readouterr().out)
|
|
156
|
+
assert payload["ok"] is False and "invalid binding" in payload["error"]
|
|
157
|
+
assert len(api[0]) == 1
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def test_cli_timeout_does_not_retry(cli_environment, monkeypatch, capsys):
|
|
161
|
+
calls = []
|
|
162
|
+
|
|
163
|
+
def get(url, **kwargs):
|
|
164
|
+
calls.append(url)
|
|
165
|
+
raise httpx.ReadTimeout("timeout")
|
|
166
|
+
|
|
167
|
+
monkeypatch.setattr(assistant_api.httpx, "get", get)
|
|
168
|
+
assert main(["assistant", "user-id", "--user-id", "123"]) == 1
|
|
169
|
+
assert json.loads(capsys.readouterr().out)["ok"] is False
|
|
170
|
+
assert len(calls) == 1
|
|
@@ -23,7 +23,7 @@ def test_auth_status_platform_override_uses_requested_platform(monkeypatch) -> N
|
|
|
23
23
|
account = AccountConfig(
|
|
24
24
|
account_id="campus-test",
|
|
25
25
|
enabled=True,
|
|
26
|
-
apiurl="https://
|
|
26
|
+
apiurl="https://campus.example.com",
|
|
27
27
|
apikey="ak_test",
|
|
28
28
|
platform="IOS",
|
|
29
29
|
)
|
|
@@ -16,7 +16,7 @@ def test_config_init_persists_magiccampus_account(monkeypatch, tmp_path) -> None
|
|
|
16
16
|
"--account",
|
|
17
17
|
"campus-test",
|
|
18
18
|
"--apiurl",
|
|
19
|
-
"https://
|
|
19
|
+
"https://campus.example.com",
|
|
20
20
|
"--apikey",
|
|
21
21
|
"ak_test",
|
|
22
22
|
"--platform",
|
|
@@ -33,7 +33,7 @@ def test_config_init_persists_magiccampus_account(monkeypatch, tmp_path) -> None
|
|
|
33
33
|
assert payload["defaultAccountId"] == "campus-test"
|
|
34
34
|
assert payload["accounts"]["campus-test"] == {
|
|
35
35
|
"enabled": True,
|
|
36
|
-
"apiUrl": "https://
|
|
36
|
+
"apiUrl": "https://campus.example.com",
|
|
37
37
|
"apiKey": "ak_test",
|
|
38
38
|
"platform": "IOS",
|
|
39
39
|
}
|
|
@@ -35,7 +35,7 @@ def test_run_user_command_returns_platform_user_payload(monkeypatch) -> None:
|
|
|
35
35
|
account = AccountConfig(
|
|
36
36
|
account_id="campus-test",
|
|
37
37
|
enabled=True,
|
|
38
|
-
apiurl="https://
|
|
38
|
+
apiurl="https://campus.example.com",
|
|
39
39
|
apikey="ak_test",
|
|
40
40
|
platform="IOS",
|
|
41
41
|
)
|
|
@@ -54,7 +54,7 @@ def test_run_feed_command_returns_user_story_page(monkeypatch) -> None:
|
|
|
54
54
|
account = AccountConfig(
|
|
55
55
|
account_id="campus-test",
|
|
56
56
|
enabled=True,
|
|
57
|
-
apiurl="https://
|
|
57
|
+
apiurl="https://campus.example.com",
|
|
58
58
|
apikey="ak_test",
|
|
59
59
|
platform="IOS",
|
|
60
60
|
)
|
|
@@ -82,7 +82,7 @@ def test_magiccampus_client_exposes_platform_domains(monkeypatch) -> None:
|
|
|
82
82
|
|
|
83
83
|
client = MagicCampusClient(
|
|
84
84
|
MagicCampusClientConfig(
|
|
85
|
-
apiurl="https://
|
|
85
|
+
apiurl="https://campus.example.com",
|
|
86
86
|
apikey="ak_test",
|
|
87
87
|
platform="IOS",
|
|
88
88
|
)
|
|
@@ -90,7 +90,7 @@ def test_magiccampus_client_exposes_platform_domains(monkeypatch) -> None:
|
|
|
90
90
|
user = client.user.get("10134002")
|
|
91
91
|
|
|
92
92
|
assert user["userId"] == "10134002"
|
|
93
|
-
assert captured["user_kwargs"]["apiurl"] == "https://
|
|
93
|
+
assert captured["user_kwargs"]["apiurl"] == "https://campus.example.com"
|
|
94
94
|
assert captured["user_kwargs"]["apikey"] == "ak_test"
|
|
95
95
|
assert captured["user_kwargs"]["user_id"] == "10134002"
|
|
96
96
|
assert captured["user_kwargs"]["timeout_seconds"] == 15.0
|