Override reference time for automated test

Hi, I am evaluating snips-nlu to use in a service that checks whether a clinic is open.
I am having trouble writing some automated tests for the date/time entity.
The problem is the tests are not reproducible because they are dependent on the time the test is run.
For example, I want to write a test for the user saying “at 3pm” when the current time is 11pm.
What is the best way to override the “reference time” that snips-nlu uses when populating the date/time entity slot result?
The snips-nlu will be running in a Python 3.7 AWS Lambda that is called by the business logic.


Hi @thelazyengineer,
The reference time used to resolve datetime entities is indeed not exposed yet in the snips-nlu API, which is indeed problematic for testing and reproducibility. This feature is on our short term roadmap and should be available soon.

In the meantime, what you can do is provide a mocked builtin entity parser to the SnipsNLUEngine object, upon creation, by running the following:

nlu_engine = SnipsNLUEngine(builtin_entity_parser=my_builtin_parser)  # When creating the engine
loaded_engine = SnipsNLUEngine.from_path(path_to_engine, builtin_entity_parser=my_builtin_parser)  # When loading a persisted engine

You can find the API of the BuiltinEntityParser object here.

I hope this helps.

thanks for the info I will try that out.