File: test_save.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 (32 lines) | stat: -rw-r--r-- 874 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import params
import pytest

"""
Test command "open-project --save"
"""


@pytest.mark.parametrize("project", [
    params.EMPTY_PROJECT_LPP_PARAM,
    params.PROJECT_WITH_TWO_BOARDS_LPPZ_PARAM,
])
def test_save(cli, project):
    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')
    original_filesize = os.path.getsize(path)
    # save project (must remove the appended zeros)
    code, stdout, stderr = cli.run('open-project', '--save', path)
    assert stderr == ''
    assert stdout == \
        "Open project '{path}'...\n" \
        "Save project...\n" \
        "SUCCESS\n".format(path=path)
    assert code == 0
    assert os.path.getsize(path) != original_filesize