pyinfra/tests/unit_tests/file_extension_parsing_test.py
Julius Unverfehrt c09476cfae Update tests
All components from payload processing downwards are tested.

Tests that depend on docker compose have been disabled by default
because they take too long to use during development. Furthermore, the
queue manager tests are not stable, a refactoring with inversion of
control is urgently needed to make the components properly testable. The
storage tests are stable and should be run once before releasing, this
should be implemented via the CI script.

Also adds, if present, tenant Id and operation kwargs to storage and
queue response.
2023-08-22 17:33:22 +02:00

33 lines
1.0 KiB
Python

import pytest
from pyinfra.utils.file_extension_parsing import make_file_extension_parser
@pytest.fixture
def file_extension_parser(file_types, compression_types):
return make_file_extension_parser(file_types, compression_types)
@pytest.mark.parametrize(
"file_path,file_types,compression_types,expected_file_extension,expected_compression_extension",
[
("test.txt", ["txt"], ["gz"], "txt", None),
("test.txt.gz", ["txt"], ["gz"], "txt", "gz"),
("test.txt.gz", [], [], None, None),
("test.txt.gz", ["txt"], [], "txt", None),
("test.txt.gz", [], ["gz"], None, "gz"),
("test", ["txt"], ["gz"], None, None),
],
)
def test_file_extension_parsing(
file_extension_parser,
file_path,
file_types,
compression_types,
expected_file_extension,
expected_compression_extension,
):
file_extension, compression_extension = file_extension_parser(file_path)
assert file_extension == expected_file_extension
assert compression_extension == expected_compression_extension