예제 #1
0
def test_discovery_plugin_find_files():
    """Test calling find files."""
    dp = DiscoveryPlugin()
    if not dp.file_command_exists():
        pytest.skip(
            "File command does not exist. Skipping test that requires it.")
    package = Package("valid_package",
                      os.path.join(os.path.dirname(__file__), "valid_package"))
    expected = [
        "CMakeLists.txt",
        "package.xml",
        "test.cpp",
        "test.sh",
    ]
    expected_fullpath = [
        os.path.join(package.path, filename) for filename in expected
    ]
    expected_file_cmd_out = [
        fullpath + ": empty\n" for fullpath in expected_fullpath
    ]
    expected_dict = {}
    for i, filename in enumerate(expected):
        expected_dict[expected_fullpath[i]] = {
            "name": filename.lower(),
            "path": expected_fullpath[i],
            "file_cmd_out": expected_file_cmd_out[i].lower(),
        }

    dp.find_files(package)

    assert package._walked  # pylint: disable=protected-access
    assert package.files == expected_dict
예제 #2
0
def test_discovery_plugin_find_files_multiple():
    """Test that find_files will only walk the path once."""
    dp = DiscoveryPlugin()
    package = Package("valid_package",
                      os.path.join(os.path.dirname(__file__), "valid_package"))
    package._walked = True  # pylint: disable=protected-access
    expected_dict = {}

    dp.find_files(package)

    assert package._walked  # pylint: disable=protected-access
    assert package.files == expected_dict