aboutsummaryrefslogtreecommitdiff
path: root/tests/test_commandline_parser.py
blob: 77836ce7aadecde008428b9df57e458face5561c (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import sys
import pytest
from avp.command import Command
from pytestqt import qtbot


def test_commandline_help(qtbot):
    command = Command()
    sys.argv = ["", "--help"]
    with pytest.raises(SystemExit):
        command.parseArgs()


def test_commandline_help_if_bad_args(qtbot):
    command = Command()
    sys.argv = ["", "--junk"]
    with pytest.raises(SystemExit):
        command.parseArgs()


def test_commandline_launches_gui_if_verbose(qtbot):
    command = Command()
    sys.argv = ["", "--verbose"]
    mode = command.parseArgs()
    assert mode == "GUI"


def test_commandline_launches_gui_if_verbose_with_project(qtbot):
    command = Command()
    sys.argv = ["", "test", "--verbose"]
    mode = command.parseArgs()
    assert mode == "GUI"


def test_commandline_tries_to_export(qtbot):
    command = Command()
    didCallFunction = False

    def captureFunction(*args):
        nonlocal didCallFunction
        didCallFunction = True

    sys.argv = ["", "-c", "0", "classic", "-i", "_", "-o", "_"]
    command.createAudioVisualization = captureFunction
    command.parseArgs()
    assert didCallFunction


def test_commandline_parses_classic_by_alias(qtbot):
    command = Command()
    assert command.parseCompName("original") == "Classic Visualizer"


def test_commandline_parses_conway_by_short_name(qtbot):
    command = Command()
    assert command.parseCompName("conway") == "Conway's Game of Life"


def test_commandline_parses_image_by_name(qtbot):
    command = Command()
    assert command.parseCompName("image") == "Image"