Changeset View
Changeset View
Standalone View
Standalone View
swh/scanner/tests/conftest.py
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | return { | ||||
"subsubdir": subsubdir, | "subsubdir": subsubdir, | ||||
"subdir": subdir, | "subdir": subdir, | ||||
} | } | ||||
@pytest.fixture(scope="function") | @pytest.fixture(scope="function") | ||||
def example_tree(temp_folder): | def example_tree(temp_folder): | ||||
"""Fixture that generate a Tree with the root present in the | """Fixture that generate a Tree with the root present in the | ||||
session fixture "temp_folder". | session fixture "temp_folder". | ||||
""" | """ | ||||
example_tree = Tree(temp_folder["root"]) | example_tree = Tree(temp_folder["root"]) | ||||
assert example_tree.path == temp_folder["root"] | assert example_tree.path == temp_folder["root"] | ||||
return example_tree | return example_tree | ||||
@pytest.fixture(scope="function") | @pytest.fixture(scope="function") | ||||
def example_dirs(example_tree, temp_folder): | def example_dirs(example_tree, temp_folder): | ||||
""" | """ | ||||
Fixture that fill the fixture example_tree with the values contained in | Fixture that fill the fixture example_tree with the values contained in | ||||
the fixture temp_folder and returns the directories information of the | the fixture temp_folder and returns the directories information of the | ||||
filled example_tree. | filled example_tree. | ||||
""" | """ | ||||
root = temp_folder["root"] | root = temp_folder["root"] | ||||
filesample_path = temp_folder["filesample"] | filesample_path = temp_folder["filesample"] | ||||
filesample2_path = temp_folder["filesample2"] | filesample2_path = temp_folder["filesample2"] | ||||
subsubdir_path = temp_folder["subsubdir"] | subsubdir_path = temp_folder["subsubdir"] | ||||
known_paths = [filesample_path, filesample2_path, subsubdir_path] | known_paths = [filesample_path, filesample2_path, subsubdir_path] | ||||
for path, pid in temp_folder["paths"].items(): | for path, pid in temp_folder["paths"].items(): | ||||
if path in known_paths: | if path in known_paths: | ||||
example_tree.addNode(path, pid) | example_tree.addNode(path, pid, True) | ||||
else: | else: | ||||
example_tree.addNode(path) | example_tree.addNode(path, pid, False) | ||||
return example_tree.getDirectoriesInfo(root) | return example_tree.getDirectoriesInfo(root) | ||||
@pytest.fixture | @pytest.fixture | ||||
def test_folder(): | def test_folder(): | ||||
"""Location of the "data" folder """ | """Location of the "data" folder """ | ||||
tests_path = PosixPath(os.path.abspath(__file__)).parent | tests_path = PosixPath(os.path.abspath(__file__)).parent | ||||
Show All 10 Lines |