Skip to content

Commit

Permalink
Data types and type annotations (#10)
Browse files Browse the repository at this point in the history
* Adding stubs and endpoints for peppol and syntax endpoints

* Fixing endpoints + adding server calls for tests

* Adding failing tests for report/peppol endpoint

* Added wellformedness testing initial

* Breakdown of welformed tests

* added .vscode folder to .gitignore

* wrote tests for case sensitive wellformedness

* updated comments

* Writing endpoints for the server and stub functions

* added some type definitions using pydantic's BaseModel

* updated some functions and tests to make use of the types

* renamed report.schema field to schemaEvaluation due to conflict with BaseModel attribute

* changed server route to match interface and fixed runtime errors

* simplified test server call

* wellformedness tests

* initial schema validation testing

* fixed import

* installed schema validation file and test xml invoice

* updated type model and corrected server call return type

* added stub returns to functions and fixed tests

* fixed types in some functions

* added example xml files and xsd file

* moved file

* added some schema tests

* added additional TODOs

* added additional type annotations and functions return stubs

* added import statement

* replaced | with Union in types for compatibility with python 3.8

* replaced list with List in types

* commented out failing tests

* fixed tests

* moved test files to correct directory

* fixed list adta type

* fixed type

* remove format from invoice type as they are all xml

* implemented wellformedness

* downloaded schema files

* added implementation outline for schema validation

* removed unnecessary files

---------

Co-authored-by: Jeremy Traini <[email protected]>
Co-authored-by: Ahona <[email protected]>
Co-authored-by: dzl-i <[email protected]>
Co-authored-by: RicardoAzzi <[email protected]>
  • Loading branch information
5 people authored Mar 10, 2023
1 parent 5d58ac0 commit 9cb94fd
Show file tree
Hide file tree
Showing 28 changed files with 50,735 additions and 255 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ dmypy.json
bin/
pyvenv.cfg
lib64

.vscode
110 changes: 96 additions & 14 deletions src/invoice.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,104 @@
from typing import Dict

def invoice_quick_fix_wellformedness_v1(report_id) -> Dict:
return {}
from src.types import *
from src.report import report_get_v1

def invoice_quick_fix_syntax_v1(report_id) -> Dict:
return {}
def invoice_quick_fix_wellformedness_v1(report_id: int) -> QuickFixReturn:
invoice = Invoice(name="My Invoice", source="text", data="data")
report = Report(
report_id=0,
score=0,
date_generated="",
invoice_name="",
invoice_raw="",
invoice_hash="",
is_valid=True,
total_num_violations=0,
wellformedness=None,
schemaEvaluation=None,
syntax=None,
peppol=None
)
quick_fix = QuickFixReturn (
invoice=invoice,
report=report
)
return quick_fix

def invoice_quick_fix_peppol_v1(report_id) -> Dict:
return {}
def invoice_quick_fix_syntax_v1(report_id: int) -> QuickFixReturn:
invoice = Invoice(name="My Invoice", source="text", data="data")
report = Report(
report_id=0,
score=0,
date_generated="",
invoice_name="",
invoice_raw="",
invoice_hash="",
is_valid=True,
total_num_violations=0,
wellformedness=None,
schemaEvaluation=None,
syntax=None,
peppol=None
)
quick_fix = QuickFixReturn (
invoice=invoice,
report=report
)
return quick_fix

def invoice_quick_fix_schema_v1(report_id) -> Dict:
return {}
def invoice_quick_fix_peppol_v1(report_id: int) -> QuickFixReturn:
invoice = Invoice(name="My Invoice", source="text", data="data")
report = Report(
report_id=0,
score=0,
date_generated="",
invoice_name="",
invoice_raw="",
invoice_hash="",
is_valid=True,
total_num_violations=0,
wellformedness=None,
schemaEvaluation=None,
syntax=None,
peppol=None
)
quick_fix = QuickFixReturn (
invoice=invoice,
report=report
)
return quick_fix

def invoice_check_validity_v1(report_id) -> Dict:
return {}
def invoice_quick_fix_schema_v1(report_id: int) -> QuickFixReturn:
invoice = Invoice(name="My Invoice", source="text", data="data")
report = Report(
report_id=0,
score=0,
date_generated="",
invoice_name="",
invoice_raw="",
invoice_hash="",
is_valid=True,
total_num_violations=0,
wellformedness=None,
schemaEvaluation=None,
syntax=None,
peppol=None
)
quick_fix = QuickFixReturn (
invoice=invoice,
report=report
)
return quick_fix

def invoice_generate_hash_v1(name, format, source, data) -> Dict:
return {}
def invoice_check_validity_v1(report_id: int) -> CheckValidReturn:
report = report_get_v1(report_id)
return CheckValidReturn(is_valid=report.is_valid, invoice_hash=report.invoice_hash)

def invoice_bulk_quick_fix_v1(invoices) -> Dict:
return {}
def invoice_generate_hash_v1(invoice: Invoice) -> str:
return "hash"

def invoice_bulk_quick_fix_v1(invoices: List[Invoice]) -> List[Invoice]:
invoice = Invoice(name="invoice", source="text", data="")
invoice_list = [invoice]
return invoice_list
Loading

0 comments on commit 9cb94fd

Please sign in to comment.