jcsambangi / bme590final_backend

Back end functionality for the HIE sensor management tool.
MIT License
1 stars 0 forks source link

Testing functions for database #16

Closed termao6 closed 5 years ago

termao6 commented 5 years ago

I have a local database that I'm querying to - do I have to have tests in TravisCI for this? I can test locally, but not sure what to do with Travis

termao6 commented 5 years ago

@mlp6 @suyashkumar

mlp6 commented 5 years ago

What type of database are you creating?

mlp6 commented 5 years ago

Regardless, you can use a pytest fixture to create a database that you can test reading/writing to.

termao6 commented 5 years ago

@mlp6 I'm using mysql, hosted locally on my computer and in python I'm using pymysql to connect to it. I looked into using fixtures, and it seems that we have to pass the database in to the functions we want to test - this seems doable, but kind of redundant passing in our 'connection' w/ mysql every time as opposed to it being a global variable we can call from anywhere in the file. Otherwise, if we do want it as a global var, we'd have to check if we're in a testing environment and config the database based on that - not entirely sure on the details of this, but I've seen in online/in other projects I've worked on, and I'm still not sure how this would work with pytest...

I guess my questions are: For the scope of this project, do we have to test these functions that involve the database in our Travis, or is it enough that we can ensure it works locally? if yes, When you say 'create a database' how would I create it so that it isn't local and so that I can test it on TravisCI? or do you have any other insights on this?

mlp6 commented 5 years ago

@suyashkumar recommendations?