pytest tests.model.test_exporters
- class tests.model.test_exporters.TestExporterBase(temp_dir: Path, date_fmt: str, time_fmt: str, uom_handling: UOMHandlingType, person: Person, datapoints_fix)
Bases:
object
A base class to be subclassed by classes that test specific exporter classes
- check_export_init(exporter: ExporterBase, person: Person, completion_dest: Callable)
Assures that the initialization of the Exporter object resulted in appropriately set properties
- Parameters
exporter (biometrics_tracker.model.exporters.ExporterBase) – the exporter instance to be checked
person (biometrics_tracker.model.datapoints.Person) – the Person instance associated with the DataPoints the exporter instance will export
completion_dest (Callable) – a callback routine to be invoked when an ImportExportCompletionMsg is received
- Returns
None
- check_row(row_nbr: int, row)
Check the column values in an exported row to assure that there are the expected number of rows, that the data corresponds to one of the DataPoint instances that were exported, and that the column values match those of the corresponding DataPoint instance
- Parameters
row_nbr (int) – The row number withing the export file
row (tuple) – a tuple of column values
- Returns
None
- create_db_connection()
Create a database connection in biometrics_tracker.model.persistence.DataBase. Setting the closed property to true causes the run routine to exit after creating the connection.
- Returns
None
- insert_datapoints(datapoints_fix) tuple[dict[str, biometrics_tracker.model.datapoints.DataPoint], datetime.datetime, datetime.datetime]
Using the DataPoints fixture to provide data, insert DataPoint rows into the test database
- Parameters
datapoints_fix (collections.NamedTuple) – a fixture that will provide biometrics_tracker.model.datapionts.DataPoint objects
- Returns
A map containing the inserted DataPoints, keyed by a string containing the Person ID, Taken datetime and the DataPointType.name value
- Return type
tuple[dict[str, biometrics_tracker.model.datapoints.DataPoint], datetime, datetime]
- send_db_close_msg()
Send a close message to the biometrics_tracker.model.persistence.DataBase instance. This methold must be used to close the database when it is being run in a separate thread
- Returns
None
- class tests.model.test_exporters.TestSQLiteExporter(temp_dir: Path, date_fmt: str, time_fmt: str, uom_handling: UOMHandlingType, person: Person, datapoints_fix)
Bases:
TestExporterBase
Tests the biometrics_tracker.model.exporters.CSVExporter class. See the doc comment for the parent class for details
- check_sqlite_export(msg: ImportExportCompletionMsg)
A callback method to be invoked on receipt of a ImportExportCompletionMsg
- Parameters
msg (biometrics_tracker.ipc.messages.ImportExportCompletionMsg) – a message containing info on the success or failure of the export process
- Returns
None
- create_field_map()
Creates a list of fields and a map with field names as keys and column indexes as values. These are used to validate the row contents from the exported file. This class needs a special version of this method because the SQLiteExporter class prepends a Person ID column the the columns specified for export by the user
- Returns
None
- test_sqlite_export(temp_dir, completion_dest: Callable)
Executes a test run of the export process for a single person
- Parameters
temp_dir (pathlib.Path) – a temporary directory path where the input database, exported files and the logs will be placed
completion_dest (Callable) – the callback method to be invoked when an ImportExportCompletionMsg is received
- Returns
None
- tests.model.test_exporters.test_csv_export(tmpdir, people_fix, datapoints_fix)
Test the CSVExporter class for a number of people. This is implemented as a module level function because pytest, or Pycharm’s pytest framework doesn’t seem to be able to properly run tests implemented as bound methods.
- Parameters
tmpdir (pytest.Fixture) – the pytest tmpdir fixture - provides a temporary directory for test output files and logs
people_fix (list[biometrics_tracker.model.datapoints.Person]) – a fixture that provides a set of Person instances
datapoints_fix (collections.NamedTuple) – a fixture that provides a set of DataPoint instances associated with contents of people_fix
- Returns
None
- tests.model.test_exporters.test_sqlite_export(tmpdir, people_fix, datapoints_fix)
Test the SQLiteExporter class for a number of people. This is implemented as a module level function because pytest,or Pycharm’s pytest framework doesn’t seem to be able to properly run tests implemented as bound methods.
- Parameters
tmpdir (pytest.Fixture) – the pytest tmpdir fixture - provides a temporary directory for test output files and logs
people_fix (list[biometrics_tracker.model.datapoints.Person]) – a fixture that provides a set of Person instances
datapoints_fix (collections.NamedTuple) – a fixture that provides a set of DataPoint instances associated with contents of people_fix
- Returns
None