Files
mlx-knife/tests_2.0/test_push_minimal.py
The BROKE Cluster Team 9261bc0c4e 2.0.0-beta.3: Feature Complete - Clone Implementation & Issue Resolution
- Clone Feature (Issue #29): Complete workspace-based workflow with ADR-007
  - Pull Preflight (Issue #30): Prevents cache pollution from gated/private repos
  - Lenient MLX Detection (Issue #31): Framework detection beyond mlx-community
  - Multi-shard Health (Issue #27): Strict completeness validation
  - Full JSON API 0.1.4: Complete schema for all 10 commands
  - Test Suite: 254/254 passed, comprehensive validation

  See CHANGELOG.md fnd TESTING.md or technical implementation details.
2025-09-18 14:09:32 +02:00

40 lines
1.2 KiB
Python

"""Minimal offline tests for experimental push operation (M0).
These tests avoid any network access and only validate local preconditions
and JSON envelope/fields.
"""
import os
from pathlib import Path
import pytest
# Skip all tests if push is not enabled
# Push tests now run by default (alpha features included in standard test suite)
from mlxk2.operations.push import push_operation, DEFAULT_PUSH_BRANCH
def test_push_requires_token(tmp_path, monkeypatch):
# Ensure no token present
monkeypatch.delenv("HF_TOKEN", raising=False)
d: Path = tmp_path / "workspace"
d.mkdir()
(d / "README.md").write_text("hello")
res = push_operation(str(d), "org/model", branch=DEFAULT_PUSH_BRANCH)
assert res["command"] == "push"
assert res["status"] == "error"
assert res["error"]["type"] == "auth_error"
assert res["data"]["repo_id"] == "org/model"
assert res["data"]["branch"] == DEFAULT_PUSH_BRANCH
def test_push_workspace_missing(monkeypatch, tmp_path):
monkeypatch.setenv("HF_TOKEN", "dummy")
missing = tmp_path / "nope"
res = push_operation(str(missing), "org/model", branch=DEFAULT_PUSH_BRANCH)
assert res["status"] == "error"
assert res["error"]["type"] == "workspace_not_found"