From 3fd3e1833e5fa32a2721d0b6a16b5fd4b43adf2a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 11 Apr 2022 15:25:54 +0300 Subject: Implement MVI for headers validity checking function Add a minimum viable implementation that passes the tests for the function that checks for the validity of the headers --- quality_control/headers.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/quality_control/headers.py b/quality_control/headers.py index b8ff160..59d3d77 100644 --- a/quality_control/headers.py +++ b/quality_control/headers.py @@ -4,4 +4,13 @@ from quality_control.errors import InvalidHeaderValue def valid_header(strains, headers): "Return the valid headers with reference to strains or throw an error" - return None + if not bool(headers[1:]): + raise InvalidHeaderValue( + "The header MUST contain at least 2 columns") + invalid_headers = tuple( + header for header in headers[1:] if header not in strains) + if invalid_headers: + raise InvalidHeaderValue( + *(f"'{header}' not a valid strain." for header in invalid_headers)) + + return headers -- cgit v1.2.3