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
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pytest
"""
Test command "open-step --minify"
"""
def test_valid_file(cli):
fp = cli.add_file('unittests/librepcbcommon/OccModelTest/model.step')
code, stdout, stderr = cli.run('open-step', '--minify', fp)
if 'LibrePCB was compiled without OpenCascade' in stderr:
pytest.skip("Feature not available.")
assert stderr == ''
assert stdout == \
"Open STEP file '{path}'...\n" \
"Perform minify...\n" \
" - Minified from 28,521 bytes to 18,336 bytes (-36%)\n" \
"Load model...\n" \
"SUCCESS\n".format(path=fp)
assert code == 0
def test_invalid_file(cli):
fp = cli.add_file('LICENSE.txt')
code, stdout, stderr = cli.run('open-step', '--minify', fp)
if 'LibrePCB was compiled without OpenCascade' in stderr:
pytest.skip("Feature not available.")
assert stderr == 'ERROR: STEP data section not found.\n'
assert stdout == \
"Open STEP file '{path}'...\n" \
"Perform minify...\n" \
"Finished with errors!\n".format(path=fp)
assert code == 1
def test_on_save_to_output(cli):
fp = cli.add_file('unittests/librepcbcommon/OccModelTest/model.step')
fp_out = cli.abspath('out.step')
code, stdout, stderr = cli.run('open-step', '--minify',
'--save-to', fp_out, fp)
if 'LibrePCB was compiled without OpenCascade' in stderr:
pytest.skip("Feature not available.")
assert stderr == ''
assert stdout == \
"Open STEP file '{path}'...\n" \
"Perform minify...\n" \
" - Minified from 28,521 bytes to 18,336 bytes (-36%)\n" \
"Save to '{outpath}'...\n" \
"Load model...\n" \
"SUCCESS\n".format(path=fp, outpath=fp_out)
assert code == 0
code, stdout, stderr = cli.run('open-step', '--minify', fp_out)
assert stderr == ''
assert stdout == \
"Open STEP file '{path}'...\n" \
"Perform minify...\n" \
" - File is already minified\n" \
"Load model...\n" \
"SUCCESS\n".format(path=fp_out)
assert code == 0
|