Example #1
0
def test_discovery_plugin_get_file_cmd_output():
    """Test get_file_cmd_output."""
    dp = DiscoveryPlugin()
    package = Package(
        "valid_package", os.path.join(os.path.dirname(__file__), "valid_package")
    )
    filepath = os.path.join(package.path, "CMakeLists.txt")
    assert filepath.lower() + ": empty\n" == dp.get_file_cmd_output(filepath)
Example #2
0
def test_discovery_plugin_get_file_cmd_output_no_file_cmd():
    """Test get_file_cmd_output when file command does not exist."""
    with modified_environ(PATH=""):
        dp = DiscoveryPlugin()
        package = Package(
            "valid_package",
            os.path.join(os.path.dirname(__file__), "valid_package"))
        filepath = os.path.join(package.path, "CMakeLists.txt")
        assert "" == dp.get_file_cmd_output(filepath)
Example #3
0
def test_discovery_plugin_get_file_cmd_output():
    """Test get_file_cmd_output."""
    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"))
    filepath = os.path.join(package.path, "CMakeLists.txt")
    assert filepath.lower() + ": empty\n" == dp.get_file_cmd_output(filepath)
Example #4
0
def test_discovery_plugin_get_file_cmd_output_calledprocess_error(
    mock_subprocess_check_output, ):
    """
    Test what happens when a CalledProcessError is raised.

    Expected result: returned empty string.
    """
    mock_subprocess_check_output.side_effect = subprocess.CalledProcessError(
        1, "", output="mocked error")
    dp = DiscoveryPlugin()
    package = Package("valid_package",
                      os.path.join(os.path.dirname(__file__), "valid_package"))
    filepath = os.path.join(package.path, "CMakeLists.txt")
    assert "" == dp.get_file_cmd_output(filepath)