diff --git a/.circleci/config.yml b/.circleci/config.yml index cfca57a6..6e9a2945 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -32,7 +32,7 @@ jobs: - run: name: Run python tests, save a coverage report, and save coverage percentage command: | - pytest --cov=. --cov-report=xml --cov-report=html:htmlcov_py --cov-report=term | tee pytest.out + python3 -m pytest --cov=. --cov-report=xml --cov-report=html:htmlcov_py --cov-report=term | tee pytest.out export NEW_PYTHON_LINES=$(cat pytest.out | grep TOTAL | awk '{print $2}' | grep -oE "[0-9]+" ) export NEW_PYTHON_HITS=$(($NEW_PYTHON_LINES - $(cat pytest.out | grep TOTAL | awk '{print $3}' | grep -oE "[0-9]+" ))) export NEW_PYTHON_PERCENT=$(cat pytest.out | grep TOTAL | awk '{print $4}' | grep -oE "[0-9]+" ) diff --git a/.gitignore b/.gitignore index 934b19f9..ba8603c4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.pot *.pyc *.pyo +.venv/ build/ dist/ helloworld.db diff --git a/bin/schema-update-utility.py b/bin/schema-update-utility.py index 74dedf75..ad058f48 100644 --- a/bin/schema-update-utility.py +++ b/bin/schema-update-utility.py @@ -11,18 +11,36 @@ def encoder_override(obj): if isinstance(obj, Decimal): # We block out Decimals in | symbols so that we can # clean them of their surrounding quotation marks later. - return '|'+str(obj)+'|' + return "|" + str(obj) + "|" return json.JSONEncoder.default(obj) def restore_decimal_values(json_string): regex = re.compile(r'"\|(.*)\|"') - return regex.sub('\\1', json_string) + return regex.sub("\\1", json_string) def process(file, schema): - print('*** ' + file) + print("*** " + file) + + report_type = { + "title": "REPORT TYPE", + "description": "", + "type": "string", + "maxLength": 5, + "examples": ["F3X"], + "fec_spec": { + "FIELD_DESCRIPTION": "REPORT TYPE", + "TYPE": "A/N-100", + "REQUIRED": "X (error)", + "SAMPLE DATA": "F3X", + "VALUE REFERENCE": None, + "RULE REFERENCE": None, + "FIELD_FORM_ASSOCIATION": None, + }, + } + # if 'filer_committee_id_number' in schema['properties']: # schema['properties']['filer_committee_id_number']['pattern'] = \ # '^[C|P][0-9]{8}$|^[H|S][0-9]{1}[A-Z]{2}[0-9]{5}$' @@ -41,47 +59,51 @@ def process(file, schema): # for property_key in schema['properties'].keys(): # del schema['properties'][property_key]['fec_spec']['COL_SEQ'] - properties = schema['properties'] - conditionals = schema.get('allOf', []) + # properties = schema['properties'] + # conditionals = schema.get('allOf', []) changed = False - for property in properties.keys(): - property_type = properties[property].get('type', []) - if property in schema.get('required', []): - if properties[property].get('minLength') == 0: - properties[property]['minLength'] = 1 - changed = True - - if isinstance(property_type, list): - if "null" in property_type: - properties[property]['type'] = "string" - changed = True - - if "examples" in properties[property]: - examples = properties[property]["examples"] - if "none" in examples: - examples.remove("none") - changed = True - - for condition in conditionals: - if property in condition['then'].get('required', []): - if property in condition['then']: - if condition['then'][property].get('minLength') == 0: - condition['then'][property]['minLength'] = 1 - changed = True - - if isinstance(property_type, list): - if "none" in property_type: - condition['then'][property]['type'] = 'string' - changed = True + if "report_type" in schema["properties"]: + schema["properties"]["report_type"] = report_type + schema["required"].pop(0) + changed = True + + # for property in properties.keys(): + # property_type = properties[property].get('type', []) + # if property in schema.get('required', []): + # if properties[property].get('minLength') == 0: + # properties[property]['minLength'] = 1 + # changed = True + + # if isinstance(property_type, list): + # if "null" in property_type: + # properties[property]['type'] = "string" + # changed = True + + # if "examples" in properties[property]: + # examples = properties[property]["examples"] + # if "none" in examples: + # examples.remove("none") + # changed = True + + # for condition in conditionals: + # if property in condition['then'].get('required', []): + # if property in condition['then']: + # if condition['then'][property].get('minLength') == 0: + # condition['then'][property]['minLength'] = 1 + # changed = True + + # if isinstance(property_type, list): + # if "none" in property_type: + # condition['then'][property]['type'] = 'string' + # changed = True return [schema, changed] -exclude_file_list = [ -] +exclude_file_list = [] -for file in (glob.glob('*.json')): +for file in glob.glob("*.json"): if file in exclude_file_list: continue @@ -93,7 +115,7 @@ def process(file, schema): schema, changed = process(file, schema) if changed: - f = open(file, 'w') + f = open(file, "w") output = json.dumps(schema, indent=4, default=encoder_override) cleaned_output = restore_decimal_values(output) diff --git a/docs/BUSINESS_LABOR_NON_CONTRIBUTION_ACCOUNT.html b/docs/BUSINESS_LABOR_NON_CONTRIBUTION_ACCOUNT.html index db11700c..1372db2f 100644 --- a/docs/BUSINESS_LABOR_NON_CONTRIBUTION_ACCOUNT.html +++ b/docs/BUSINESS_LABOR_NON_CONTRIBUTION_ACCOUNT.html @@ -1,4 +1,5 @@ - FEC Non-contribution Account

FEC Non-contribution Account

Type: object

Non-contribution Account (17)

Type: const
Specific value: "SA17"
Example:

"SA17"
+ FEC Non-contribution Account 

FEC Non-contribution Account

Type: object

Non-contribution Account (17)

Type: string

Must be at most 5 characters long


Example:

"F3X"
+

Type: const
Specific value: "SA17"
Example:

"SA17"
 

Type: string
Must match regular expression: ^(?:[PC][0-9]{8}|[HS][0-9]{1}[A-Z]{2}[0-9]{5})$

Must be at least 9 characters long

Must be at most 9 characters long


Example:

"C00123456"
 

Type: const
Specific value: "BUSINESS_LABOR_NON_CONTRIBUTION_ACCOUNT"
Example:

"BUSINESS_LABOR_NON_CONTRIBUTION_ACCOUNT"
 

Type: string
Must match regular expression: ^[ -~]{0,20}$

Must be at least 1 characters long

Must be at most 20 characters long


Example:

"A56123456789-1234"
@@ -16,4 +17,4 @@
 

Type: const
Specific value: "NON_CONTRIBUTION_ACCOUNT"
Example:

"NON_CONTRIBUTION_ACCOUNT"
 

Type: const
Specific value: "Non-contribution Account"
Example:

"Non-contribution Account"
 

Type: boolean or null

Type: string or null
Must match regular expression: ^[ -~]{0,100}$

Type: enum (of string or null)

Must be one of:

  • "REATTRIBUTED"
  • "REDESIGNATED"
  • "REATTRIBUTION_FROM"
  • "REATTRIBUTION_TO"
  • "REDESIGNATION_FROM"
  • "REDESIGNATION_TO"
  • null

Example:

"REATTRIBUTED"
-
\ No newline at end of file +
\ No newline at end of file diff --git a/docs/BUSINESS_LABOR_NON_CONTRIBUTION_ACCOUNT_spec.html b/docs/BUSINESS_LABOR_NON_CONTRIBUTION_ACCOUNT_spec.html index 406e8f6c..b21ff0e3 100644 --- a/docs/BUSINESS_LABOR_NON_CONTRIBUTION_ACCOUNT_spec.html +++ b/docs/BUSINESS_LABOR_NON_CONTRIBUTION_ACCOUNT_spec.html @@ -9,6 +9,16 @@ VALIDATION RULES +REPORT TYPE +A/N-100 + + + + + +