Example #1
0
def test_determine_duplicated_loc_raises_exception_when_provided_string_is_corrupt(
):
    """Test that 0 is returned when the provided string is empty."""

    # arrange
    data = "hello"

    # act & assert
    with pytest.raises(ValueError):
        determine_duplicate_lines_of_code(data)
Example #2
0
def test_determine_duplicated_loc_raises_exception_when_lines_count_is_string(
):
    """Test that 0 is returned when the line_count is a string."""

    # arrange
    data = (
        "lines,tokens,occurrences\n"
        "40, 84, 2, 210,\\west\\west_dotcover.py, 19,\\west\\west_resharper_profile.py\n"
        "bla, 78, 2, 76,\\west\\west_riskmatrix.py, 105,\\west\\west_riskmatrix.py\n"
        "34, 82, 3, 213,\\west\\west_dotcover.py, 7,\\west\\west_reporting.py, 22, \\west\\wet_resharper.py\n"
    )

    # act & assert
    with pytest.raises(ValueError):
        determine_duplicate_lines_of_code(data)
Example #3
0
def test_determine_duplicated_loc_raises_when_provided_string_has_wrong_header(
):
    """Test that 0 is returned when the provided string is has a wrong header."""

    # arrange
    data = (
        "hello,tokens,occurrences\n"
        "40, 84, 2, 210,\\west\\west_dotcover.py, 19,\\west\\west_resharper_profile.py\n"
        "15, 78, 2, 76,\\west\\west_riskmatrix.py, 105,\\west\\west_riskmatrix.py\n"
        "34, 82, 3, 213,\\west\\west_dotcover.py, 7,\\west\\west_reporting.py, 22, \\west\\wet_resharper.py\n"
    )

    # act & assert
    with pytest.raises(ValueError):
        determine_duplicate_lines_of_code(data)
Example #4
0
def test_determine_duplicated_loc_returns_0_when_provided_string_is_empty():
    """Test that 0 is returned when the provided string is empty."""

    # arrange
    data = ""

    # act
    duplicated_loc = int(determine_duplicate_lines_of_code(data))

    # assert
    assert duplicated_loc == 0
Example #5
0
def test_determine_duplicated_loc_calculates_correct_number_of_duplicated_lines(
):
    """Test that the number of duplicated lines of code is calculated correctly."""

    # arrange
    data = (
        "lines,tokens,occurrences\n"
        "40, 84, 2, 210,\\west\\west_dotcover.py, 19,\\west\\west_resharper_profile.py\n"
        "15, 78, 2, 76,\\west\\west_riskmatrix.py, 105,\\west\\west_riskmatrix.py\n"
        "34, 82, 3, 213,\\west\\west_dotcover.py, 7,\\west\\west_reporting.py, 22, \\west\\wet_resharper.py\n"
    )

    # act
    duplicated_loc = int(determine_duplicate_lines_of_code(data))

    # assert
    assert duplicated_loc == 212