File size: 1,231 Bytes
1533f24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from __future__ import annotations

import pytest

from moss4gb.cli import _parse_skip, build_parser


def test_parse_skip():
    assert _parse_skip("22") == (22,)
    assert _parse_skip("22,24,26") == (22, 24, 26)
    assert _parse_skip("") == ()
    assert _parse_skip("none") == ()
    assert _parse_skip("off") == ()


def test_generate_defaults():
    args = build_parser().parse_args(["generate"])
    assert (args.height, args.width) == (512, 512)
    assert args.steps == 20
    assert args.cfg == 3.0
    assert args.compute_dtype == "float16"
    assert args.vae_device == "cpu"
    from pathlib import Path

    assert Path(args.bank) == Path("assets/bank")


def test_bank_build_requires_a_prompt():
    args = build_parser().parse_args(["bank", "build", "--dry-run", "--prompt", "x"])
    assert args.bank_action == "build" and args.dry_run and args.prompt == ["x"]


def test_subcommand_is_required():
    with pytest.raises(SystemExit):
        build_parser().parse_args([])


def test_generate_cache_flags():
    args = build_parser().parse_args(["generate"])
    assert args.cache is None and args.no_cache is False
    args = build_parser().parse_args(["generate", "--no-cache"])
    assert args.no_cache is True