Skip to content

Commit

Permalink
Merge pull request #344 from IATI/develop
Browse files Browse the repository at this point in the history
fix: change tests to check explicitly for True, False
  • Loading branch information
simon-20 authored Aug 2, 2024
2 parents 62224fc + 5b20136 commit 29f9610
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/library/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def process_hash_list(document_datasets):
file_schema_valid = file_data[6]
publisher_black_flag = file_data[7] is not None

if not file_schema_valid and downloaded > (
if file_schema_valid is False and downloaded > (
now - timedelta(hours=config["VALIDATION"]["SAFETY_CHECK_PERIOD"])
):
logger.info(
Expand All @@ -43,7 +43,7 @@ def process_hash_list(document_datasets):
)
continue

if not file_schema_valid and publisher_black_flag:
if file_schema_valid is False and publisher_black_flag is True:
logger.info(
"Skipping Schema Invalid file for Full Validation since publisher: "
f"{publisher} is black flagged for hash: {file_hash} and id: {file_id}"
Expand Down Expand Up @@ -104,7 +104,7 @@ def process_hash_list(document_datasets):
)
try:
body = schema_response.json()
if body["valid"] or not body["valid"]:
if body["valid"] is True or body["valid"] is False:
db.updateDocumentSchemaValidationStatus(conn, file_id, body["valid"])
file_schema_valid = body["valid"]
else:
Expand All @@ -115,7 +115,7 @@ def process_hash_list(document_datasets):
)
continue

if not file_schema_valid and downloaded > (
if file_schema_valid is False and downloaded > (
now - timedelta(hours=config["VALIDATION"]["SAFETY_CHECK_PERIOD"])
):
logger.info(
Expand All @@ -125,7 +125,7 @@ def process_hash_list(document_datasets):
)
continue

if not file_schema_valid and publisher_black_flag:
if file_schema_valid is False and publisher_black_flag is True:
logger.info(
f"Skipping Schema Invalid file for Full Validation since publisher: {publisher} "
f"is flagged for hash: {file_hash} and id: {file_id}"
Expand All @@ -141,7 +141,7 @@ def process_hash_list(document_datasets):
full_url = config["VALIDATION"]["FULL_VALIDATION_URL"]

# only need meta=true for invalid files to "clean" them later
if not file_schema_valid:
if file_schema_valid is False:
full_url += "?meta=true"
full_response = requests.post(
full_url,
Expand Down

0 comments on commit 29f9610

Please sign in to comment.