# Copyright 2022-2026 The Ramble Authors
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
import os
import pytest
import ramble.cmd.results
import ramble.paths
INPUT_DATA = os.path.join(ramble.paths.test_path, "data", "results_upload")
[docs]
@pytest.mark.parametrize(
"filename,expected_output",
[
(
os.path.join(INPUT_DATA, "test1_empty_experiments.json"),
"Does not contain valid data to import.",
),
(
os.path.join(INPUT_DATA, "test2_not_json.txt.json"),
"Invalid JSON formatting.",
),
(
os.path.join(INPUT_DATA, "test3_malformed_json.json"),
"Invalid JSON formatting",
),
],
)
def test_file_import_rejects_invalid_files(filename, expected_output, capsys):
with pytest.raises(SystemExit):
ramble.cmd.results.import_results_file(filename)
captured = capsys.readouterr().err
assert expected_output in captured