2020-12-29 12:10:18 -05:00
|
|
|
"""Unit tests: report_invalid_alts"""
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2023-07-10 15:43:17 -04:00
|
|
|
@pytest.mark.parametrize("valid", [True, False], ids=["valid", "no_valid"])
|
|
|
|
@pytest.mark.parametrize("previous", [True, False], ids=["prev", "no_prev"])
|
2020-12-29 12:10:18 -05:00
|
|
|
def test_report_invalid_alts(runner, yadm, valid, previous):
|
|
|
|
"""Use report_invalid_alts"""
|
|
|
|
|
2023-07-10 15:43:17 -04:00
|
|
|
lwi = ""
|
|
|
|
alts = "INVALID_ALT=()"
|
2020-12-29 12:10:18 -05:00
|
|
|
if previous:
|
2023-07-10 15:43:17 -04:00
|
|
|
lwi = "LEGACY_WARNING_ISSUED=1"
|
2020-12-29 12:10:18 -05:00
|
|
|
if not valid:
|
|
|
|
alts = 'INVALID_ALT=("file##invalid")'
|
|
|
|
|
|
|
|
script = f"""
|
|
|
|
YADM_TEST=1 source {yadm}
|
|
|
|
{lwi}
|
|
|
|
{alts}
|
|
|
|
report_invalid_alts
|
|
|
|
"""
|
2023-07-10 15:43:17 -04:00
|
|
|
run = runner(command=["bash"], inp=script)
|
2020-12-29 12:10:18 -05:00
|
|
|
assert run.success
|
2023-07-10 15:43:17 -04:00
|
|
|
assert run.out == ""
|
2020-12-29 12:10:18 -05:00
|
|
|
if not valid and not previous:
|
2023-07-10 15:43:17 -04:00
|
|
|
assert "WARNING" in run.err
|
|
|
|
assert "file##invalid" in run.err
|
2020-12-29 12:10:18 -05:00
|
|
|
else:
|
2023-07-10 15:43:17 -04:00
|
|
|
assert run.err == ""
|