Skip to content

Commit

Permalink
Simple QA demo
Browse files Browse the repository at this point in the history
  • Loading branch information
phynes-sensiblecode committed May 12, 2022
1 parent 32bad86 commit 366fff6
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions qa/qa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import csv
import os
import sys

input_dir = ''
if len(sys.argv) > 1:
input_dir = sys.argv[1]

classifications = {}
with open(os.path.join(input_dir, 'Classification.csv'), newline='', encoding='utf-8-sig') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
classifications[row['Classification_Mnemonic']] = row

categories = {}
with open(os.path.join(input_dir, 'Category.csv'), newline='', encoding='utf-8-sig') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
classification_mnemonic = row['Classification_Mnemonic']
if classification_mnemonic not in categories:
categories[classification_mnemonic] = []
categories[classification_mnemonic].append(row['Category_Code'])

for mnemonic, classification in classifications.items():
if mnemonic not in categories:
print(f'No categories for classification {mnemonic}')
continue

expected_num_cats = int(classifications[mnemonic]['Number_Of_Category_Items'])
cats = categories[mnemonic]
if expected_num_cats and expected_num_cats != len(cats):
print(f'Expected {expected_num_cats} categories for classification {mnemonic} but found {len(cats)}')
continue

if len(cats) != len(set(cats)):
duplicate_codes = [c for c in cats if cats.count(c) > 1]
print(f'Duplicate categories {duplicate_codes} found for classification {mnemonic}')

0 comments on commit 366fff6

Please sign in to comment.