def test_main(tmpdir):

    topology = tmpdir.join('topology.txt')
    topology.write(TEST_TOPOLOGY)

    arguments = ['--platform=debug', '--non-interactive', str(topology)]
    assert main.main(args.parse_args(arguments)) == 0
def test_args(tmpdir):

    topology = tmpdir.join('topology.txt')
    topology.write('')

    parsed = args.parse_args([str(topology)])
    assert parsed.verbose == 0

    parsed = args.parse_args(['-v', str(topology)])
    assert parsed.verbose == 1

    parsed = args.parse_args(['-vv', str(topology)])
    assert parsed.verbose == 2

    parsed = args.parse_args(['-vvv', str(topology)])
    assert parsed.verbose == 3
def test_main(tmpdir):

    topology = tmpdir.join('topology.txt')
    topology.write(TEST_TOPOLOGY)

    arguments = ['--platform=debug', '--non-interactive', str(topology)]
    assert main.main(args.parse_args(arguments)) == 0
Beispiel #4
0
def test_args(tmpdir):

    with pytest.raises(InvalidArgument):
        parse_args(['/this/doesnt/exists.szn'])

    topology = tmpdir.join('topology.szn')
    topology.write('')

    parsed = parse_args([str(topology)])
    assert parsed.verbose == 0

    parsed = parse_args(['-v', str(topology)])
    assert parsed.verbose == 1

    parsed = parse_args(['-vv', str(topology)])
    assert parsed.verbose == 2

    parsed = parse_args(['-vvv', str(topology)])
    assert parsed.verbose == 3

    # Validate option parsing
    with pytest.raises(InvalidArgument):
        parsed = parse_args([
            str(topology),
            '--option',
            '1argument=100',
        ])

    with pytest.raises(InvalidArgument):
        parsed = parse_args([
            str(topology),
            '--option',
            '$argument=100',
        ])

    parsed = parse_args([
        str(topology),
        '--option',
        'var-1=Yes',
        'var2=no',
        'var_3=TRUE',
        'var4=100',
        '--option',
        'var4=200',
        'var5=helloworld',
        'var6=/tmp/a/path',
        '--option',
        'var7=1.7560',
    ])

    expected = OrderedDict([
        ('var_1', True),
        ('var2', False),
        ('var_3', True),
        ('var4', 200),
        ('var5', 'helloworld'),
        ('var6', '/tmp/a/path'),
        ('var7', 1.7560),
    ])

    ddiff = DeepDiff(parsed.options, expected)
    assert not ddiff