File: test_open.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 (77 lines) | stat: -rw-r--r-- 2,491 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import params
import pytest

"""
Test command "open-library"
"""


@pytest.mark.parametrize("library", [
    params.EMPTY_LIBRARY_PARAM,
    params.POPULATED_LIBRARY_PARAM,
])
def test_open_library_absolute_path(cli, library):
    cli.add_library(library.dir)
    code, stdout, stderr = cli.run('open-library', cli.abspath(library.dir))
    assert stderr == ''
    assert stdout == \
        "Open library '{dir}'...\n" \
        "SUCCESS\n".format(dir=cli.abspath(library.dir))
    assert code == 0


@pytest.mark.parametrize("library", [
    params.EMPTY_LIBRARY_PARAM,
    params.POPULATED_LIBRARY_PARAM,
])
def test_open_library_relative_path(cli, library):
    cli.add_library(library.dir)
    code, stdout, stderr = cli.run('open-library', library.dir)
    assert stderr == ''
    assert stdout == \
        "Open library '{library.dir}'...\n" \
        "SUCCESS\n".format(library=library)
    assert code == 0


@pytest.mark.parametrize("library", [
    params.EMPTY_LIBRARY_PARAM,
    params.POPULATED_LIBRARY_PARAM,
])
def test_open_library_all(cli, library):
    cli.add_library(library.dir)
    code, stdout, stderr = cli.run('open-library', '--all', library.dir)
    assert stderr == ''
    assert stdout == \
        "Open library '{library.dir}'...\n" \
        "Process {library.cmpcat} component categories...\n" \
        "Process {library.pkgcat} package categories...\n" \
        "Process {library.sym} symbols...\n" \
        "Process {library.pkg} packages...\n" \
        "Process {library.cmp} components...\n" \
        "Process {library.dev} devices...\n" \
        "SUCCESS\n".format(library=library)
    assert code == 0


@pytest.mark.parametrize("library", [
    params.POPULATED_LIBRARY_PARAM,
])
def test_open_library_all_verbose(cli, library):
    cli.add_library(library.dir)
    code, stdout, stderr = cli.run('open-library', '--all', '--verbose',
                                   library.dir)
    assert len(stderr) > 100  # logging messages are on stderr
    assert stdout == \
        "Open library '{library.dir}'...\n" \
        "Process {library.cmpcat} component categories...\n" \
        "Process {library.pkgcat} package categories...\n" \
        "Process {library.sym} symbols...\n" \
        "Process {library.pkg} packages...\n" \
        "Process {library.cmp} components...\n" \
        "Process {library.dev} devices...\n" \
        "SUCCESS\n".format(library=library)
    assert code == 0