Doveps / mono

Code for Doveps projects
http://doveps.com
MIT License
0 stars 0 forks source link

03-21-2018 Report: Searching for way to connect psycopg2 to running postgres in machine #128

Closed JosiahRegencia closed 6 years ago

JosiahRegencia commented 6 years ago

I only deleted a few code from fix_test_discrepancy branch. Most of what I did was reading. My docker seems to be doing well locally. I think we can stop using DigitalOcean for now.

screenshot from 2018-03-21 12-30-14

Got that result from running tests inside docker containers.

I got an idea in this site: https://julien.danjou.info/db-integration-testing-strategies-python/ to get the url of the running postgres in the machine. Whether it's in docker or other kind of machine. Still trying to figure out how to get it and use psycopg2 to connect it.

Other readings include using some library called mock https://www.xaprb.com/blog/2008/08/19/how-to-unit-test-code-that-interacts-with-a-database/ https://stackoverflow.com/questions/35143055/how-to-mock-psycopg2-cursor-object

greenmoss commented 6 years ago

Thanks for note on Digital Ocean. I removed the VM. I noticed it said "0$ used this month", so maybe I didn't have to do that...

For testing: when you are inside the savant container, as launched by docker-compose, the db address is just db. That will be the normal case. If you are testing locally on Linux outside of Docker, the db address is localhost.

Testing using the savant container outside docker-compose would require an IP address, but I think we don't need to do that.