1
+ import logging
2
+ import sqlite3
3
+ from digital_land .expectations .operation import (
4
+ check_columns
5
+ )
6
+
7
+ logger = logging .getLogger ("__name__" )
8
+
9
+ EXPECTED = {
10
+ "endpoint_dataset_issue_type_summary" : ['organisation' , 'organisation_name' , 'cohort' , 'dataset' , 'collection' , 'pipeline' , 'endpoint' , 'endpoint_url' , 'resource' , 'resource_start_date' , 'resource_end_date' , 'latest_log_entry_date' , 'count_issues' , 'date' , 'issue_type' , 'severity' , 'responsibility' , 'fields' ],
11
+ "endpoint_dataset_resource_summary" : ['organisation' , 'organisation_name' , 'cohort' , 'dataset' , 'collection' , 'pipeline' , 'endpoint' , 'endpoint_url' , 'resource' , 'resource_start_date' , 'resource_end_date' , 'latest_log_entry_date' , 'mapping_field' , 'non_mapping_field' ],
12
+ "endpoint_dataset_summary" : ['organisation' , 'dataset' , 'endpoint' , 'endpoint_url' , 'resource' , 'latest_status' , 'latest_exception' , 'latest_log_entry_date' , 'entry_date' , 'end_date' , 'latest_resource_start_date' , 'resource_end_date' ],
13
+ "provision_summary" : ['organisation' , 'organisation_name' , 'dataset' , 'provision_reason' , 'active_endpoint_count' , 'error_endpoint_count' , 'count_issue_error_internal' , 'count_issue_error_external' , 'count_issue_warning_internal' , 'count_issue_warning_external' , 'count_issue_notice_internal' , 'count_issue_notice_external' ],
14
+ "reporting_historic_endpoints" : ['organisation' , 'name' , 'organisation_name' , 'dataset' , 'collection' , 'pipeline' , 'endpoint' , 'endpoint_url' , 'licence' , 'latest_status' , 'latest_exception' , 'resource' , 'latest_log_entry_date' , 'endpoint_entry_date' , 'endpoint_end_date' , 'resource_start_date' , 'resource_end_date' ],
15
+ "reporting_latest_endpoints" : ['organisation' , 'name' , 'organisation_name' , 'dataset' , 'collection' , 'pipeline' , 'endpoint' , 'endpoint_url' , 'licence' , 'latest_status' , 'days_since_200' , 'latest_exception' , 'resource' , 'latest_log_entry_date' , 'endpoint_entry_date' , 'endpoint_end_date' , 'resource_start_date' , 'resource_end_date' , 'rn' ]
16
+ }
17
+
18
+ def check_performance_columns ():
19
+ try :
20
+ conn = sqlite3 .connect ("dataset/performance.sqlite3" ).cursor ()
21
+ result , message , details = check_columns (conn , EXPECTED )
22
+ if not result :
23
+ logging .error ("Column check failed for performance DB" )
24
+ logging .error (message )
25
+ for item in details :
26
+ if not item ["success" ]:
27
+ logging .error (f"{ item ['table' ]} did not have all expected columns. Missing columns: { item ['missing' ]} " )
28
+ logging .error (f"Columns found: { item ['actual' ]} " )
29
+ raise Exception (f"Performance DB check failed: { message } " )
30
+ finally :
31
+ conn .close ()
32
+
33
+
34
+ if __name__ == "__main__" :
35
+ check_performance_columns ()
0 commit comments