File: test_strict.py

package info (click to toggle)
librepcb 1.2.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 58,484 kB
  • sloc: cpp: 267,986; python: 12,100; ansic: 6,899; xml: 234; sh: 215; makefile: 115; perl: 73
file content (52 lines) | stat: -rw-r--r-- 1,693 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import params

"""
Test command "open-project --strict"
"""


def test_valid_lpp(cli):
    project = params.EMPTY_PROJECT_LPP
    cli.add_project(project.dir, as_lppz=project.is_lppz)
    code, stdout, stderr = cli.run('open-project', '--strict', project.path)
    assert stderr == ''
    assert stdout == \
        "Open project '{project.path}'...\n" \
        "Check for non-canonical files...\n" \
        "SUCCESS\n".format(project=project)
    assert code == 0


def test_invalid_lpp(cli):
    project = params.EMPTY_PROJECT_LPP
    cli.add_project(project.dir, as_lppz=project.is_lppz)
    # append some zeros to the project file
    path = cli.abspath(project.path)
    with open(path, 'ab') as f:
        f.write(b'\0\0')
    # open project
    code, stdout, stderr = cli.run('open-project', '--strict', project.path)
    assert stderr == \
        "    - Non-canonical file: '{project.path}'\n" \
        .format(project=project)
    assert stdout == \
        "Open project '{project.path}'...\n" \
        "Check for non-canonical files...\n" \
        "Finished with errors!\n".format(project=project)
    assert code == 1


def test_lppz_fails(cli):
    project = params.PROJECT_WITH_TWO_BOARDS_LPPZ
    cli.add_project(project.dir, as_lppz=project.is_lppz)
    code, stdout, stderr = cli.run('open-project', '--strict', project.path)
    assert stderr == \
        "  ERROR: The option '--strict' is not available for *.lppz files!\n"
    assert stdout == \
        "Open project '{project.path}'...\n" \
        "Check for non-canonical files...\n" \
        "Finished with errors!\n".format(project=project)
    assert code == 1