vitalseeds / vs-data-api

Fast API endpoints to expose vs-data actions for to run from Filemaker
MIT License
0 stars 0 forks source link

Add testing framework (mocks) #2

Open tombola opened 1 year ago

tombola commented 1 year ago

Should support the following testing

tombola commented 1 year ago

Will need to mock external data sources:

Hopefully can provide a set of pytest marks (eg). that will run the corresponding recordings of live requests against local database. This would keep test more maintainable, as can re-run against new copy of database and commit the responses.

tombola commented 1 year ago

I have added mocking for WooCommerce, which will make testing that aspect simple and fast.

Next is testing the odbc connection* against an SQLite database in place of filemaker, and dumping some test data in there from the relevant filemaker tables, eg acquisitions, seed_lots, batches. Should include some non test data to catch edge cases.

Resources re odbc mock:

* pypyodbc unless I can build pyodbc against iodbc

tombola commented 1 year ago

Testing stock database (ideally against sqlite)

Is SQLite a viable drop in replacement

First must check if SQL syntax used is equivalent between sqlite and FileMaker (🤞). Do this by constructing two simple tables in SQLite with as columns as per vs_tables.py then take some generated SQL (eg from batch_upload.py) and perform the (joined) query against sqlite instead.

Options for mocking:

To recreate fm in sqlite, could: