SimonbJohnson / quickX3

HXLDash. Create data visualisations quickly by leveraging the humanitarian exchange language
https://hxldash.com/
MIT License
8 stars 4 forks source link

(Discussion) CLI command to populate the hxldash database with predictable sample data #69

Closed fititnt closed 4 years ago

fititnt commented 4 years ago

Issue started at https://github.com/SimonbJohnson/quickX3/issues/66

TL;DR: At this moment the command python manage.py migrate is used to prepare the databases (both initial and upgrades). This issue is about discussion about some additional CLI command that may be executed just after python manage.py migrate that may add fake (but predictable) data.


Disclaimer: at this point I don't have knowledge about potential more easy ways (or already standards on how to do it) with Python or Django. So this issue at this point may be more generic. If later I found some reference projects or documentation on this topic I may add.

All comments from here is about explaining user cases and things that may be relevant just later, but I'm adding upfront. But for anyone else reading, the 'TL;DR:' already explained what mostly likely could result from this.

Use cases

1. Aid (human) user testing

New people who may help with testing small changes, even if try to make a local copy, may actually not be fully aware on how to add all the dashboards options.

With such command, the person may actually be able to see some data and also when editing the code may be able to see if something breaks.

It may not replace human review, but it may be very useful.

2. Have potential to be used for automated testing

By having an cli command that preload the data in a predictable way, to a point of some URLs are expected to have some very specific content, it is the perfect scenario for later add automated testing. So at some point after having a command to populate the sample data, is possible to receive Pull Requests to add extra command to run and check this data.

While the sample data may have much more data (to help humans testing) depending on how the automated testing be implemented, this may force the testing code be updated more often. The good part is that sometimes this means do "a search and replace for strings" on both the sample data and the test command and may work at first try.

At least one sample data optimized for non-human

One way to optimize later these "search and replace" and also make easier automated testing is to from start have at least two spreadsheets that may be the same untill need to make more complex (or detailed) tests. The quickstart uses this one: https://docs.google.com/spreadsheets/d/1R9zfMTk7SQB8VoEp4XK0xAWtlsQcHgEvYiswZsj9YA4/edit#gid=0.

Captura de tela de 2020-04-06 07-41-01

At some point on future, the sample data that would be used for automated testing could have differences like this

Things that intentionally may be a good idea not change on sample data:

SimonbJohnson commented 4 years ago

Thanks for this. I'm hoping to find time this weekend to implement this at least for an online version.

SimonbJohnson commented 4 years ago

@fititnt - I've added the command populate_database which creates the 3 dashboards from the tutorials. It should be easy now to add further dashboards to data.json for testing purposes.

It is on branch adding-populate-database-command

Let me know if this is as you expected and I will merge.

fititnt commented 4 years ago

@SimonbJohnson Great! I will start testing right now.

fititnt commented 4 years ago

@SimonbJohnson I can confirm that the command works.

Here a test server, with link for the tree dashboards https://dash.hxl.etica.dev/view/1 https://dash.hxl.etica.dev/view/2 https://dash.hxl.etica.dev/view/3

suggestion 1: Sample with password

One thing that could be added (even if is not a different dashboard) is a sample with a pre-defined password. This later can be used as a automated test to check if the function stopped to work.

Suggestion 2: document the new command

Its a good idea to add python manage.py populate_database to the README.md. But the minimum functionality already works.

The only thing that I did not fully tested is using with non-SQLite database, but the command works.

SimonbJohnson commented 4 years ago

Added with suggestions https://github.com/SimonbJohnson/quickX3/pull/76