Mesnage-Org / pgfinder

Peptidoglycan MS1 Analysis Tool
https://mesnage-org.github.io/pgfinder
GNU Lesser General Public License v3.0
4 stars 2 forks source link

Improve tests to cover raising of errors when reading structures #251

Open ns-rse opened 1 year ago

ns-rse commented 1 year ago

Stemming from a PR review #249 the check that a UserError and ValueError are raised introduced to pgfinder/pgio.py (line 174)...

    # Check that all structures are followed by "|n" where n is one or more digits
    if not theo_masses_df["Inferred structure"].str.contains(r"\|\d+$").all():
        raise UserError(

Isn't tested according to CodeCov.

Should be relatively straight-forward to construct a test for this (and other checks if they're not already covered) by having a simple CSV without the |[1|2] construct and using the...

@pytest.mark.parameterize(
    "file,error", 
    [

   ("tests/resources/file1.csv", UserError),

   ("tests/resources/file2.csv", ValueError),
]
)
def test_exceptions(file: str, error) -> None:
    with pytest.raises(error)
        assert theo_masses_reader(file)

(or similar, bit of a rough hack/guess at the code).

_Originally posted by @ns-rse in https://github.com/Mesnage-Org/pgfinder/pull/249#discussion_r1360562172_