e0e362d700
SDK Tests / SDK CI (push) Blocked by required conditions
SDK Tests / changes (push) Successful in 2m29s
Real E2E Tests / changes (push) Successful in 2m29s
SDK Tests / Python SDK Tests (sandbox) (push) Waiting to run
SDK Tests / CLI Quality (push) Waiting to run
SDK Tests / CLI Tests (push) Waiting to run
SDK Tests / Python SDK Quality (code-interpreter) (push) Waiting to run
SDK Tests / Python SDK Quality (sandbox) (push) Waiting to run
SDK Tests / Python SDK Tests (code-interpreter) (push) Waiting to run
SDK Tests / JavaScript SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / JavaScript SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Kotlin SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Kotlin SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / C# SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / C# SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Go SDK Quality And Tests (push) Waiting to run
Deploy Docs Pages / build (push) Has been cancelled
Deploy Docs Pages / deploy (push) Has been cancelled
Real E2E Tests / JavaScript E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Python E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Java E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / C# E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Go E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Real E2E CI (push) Has been cancelled
63 lines
2.1 KiB
Python
63 lines
2.1 KiB
Python
# Copyright 2025 Alibaba Group Holding Ltd.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
from datetime import datetime
|
|
|
|
from opensandbox_server.services.snapshot_models import (
|
|
SnapshotRecord,
|
|
SnapshotRestoreConfig,
|
|
SnapshotState,
|
|
SnapshotStatusRecord,
|
|
)
|
|
|
|
|
|
def test_snapshot_record_defaults_are_runtime_agnostic() -> None:
|
|
record = SnapshotRecord(
|
|
id="snap-001",
|
|
source_sandbox_id="sbx-001",
|
|
name="before-install",
|
|
description="snapshot before dependency install",
|
|
)
|
|
|
|
assert record.id == "snap-001"
|
|
assert record.source_sandbox_id == "sbx-001"
|
|
assert record.restore_config.image is None
|
|
assert record.status.state == SnapshotState.CREATING
|
|
assert record.status.reason is None
|
|
assert record.status.message is None
|
|
assert isinstance(record.created_at, datetime)
|
|
assert isinstance(record.updated_at, datetime)
|
|
|
|
|
|
def test_snapshot_record_supports_ready_restore_config() -> None:
|
|
ready_at = datetime.utcnow()
|
|
|
|
record = SnapshotRecord(
|
|
id="snap-002",
|
|
source_sandbox_id="sbx-002",
|
|
restore_config=SnapshotRestoreConfig(
|
|
image="registry.example.com/snapshots/snap-002:latest"
|
|
),
|
|
status=SnapshotStatusRecord(
|
|
state=SnapshotState.READY,
|
|
reason="snapshot_ready",
|
|
message="Snapshot is ready.",
|
|
last_transition_at=ready_at,
|
|
),
|
|
)
|
|
|
|
assert record.restore_config.image == "registry.example.com/snapshots/snap-002:latest"
|
|
assert record.status.state == SnapshotState.READY
|
|
assert record.status.last_transition_at == ready_at
|