Open-event-server: Use Postgres database for unit testing

Created on 11 Jan 2017  路  8Comments  路  Source: fossasia/open-event-server

Related: #2881

Currently open event uses SQLite database for testing (both locally and on Travis). This approach has a number of problems.

  1. DateTime field is not natively supported in SQLite. It is just a string in SQLite so testing date-time database fields becomes difficult. (I was writing tests for pentabarf export/import and there I noticed this issue. I remember facing the same issue a lot of times in the past summer but I always used workarounds to get through.)
  2. Other advanced datatypes like Color field are not supported in SQLite.
  3. A production server will most probably run on Postgres. So it is in our advantage to test using the same database engine.

To do this, minor changes will be required in the code and documentation. The changes are working fine so far in my local system.

testing

Most helpful comment

Okay ... Looks like testing config is overriding the env at tests/unittests/setup_database.py .. So, just that line should be changed

All 8 comments

@aviaryan locally you can run it on postgreSQL. I am myself running it locally on postgreSQL. You can see the documentation for setting it up locally which does mention using postgreSQL. The issue isn't clear to me.

@SaptakS I think you missed my point here. I am talking about unit testing, not running.

@aviaryan we are already using Postgres in testing

Okay ... Looks like testing config is overriding the env at tests/unittests/setup_database.py .. So, just that line should be changed

@niranjan94 It may seem like that but setup_database.py which is responsible for testing application has DATABASE_URL hard-coded. So in reality, SQLite is being used.

@aviaryan @niranjan94 yeah it needs to changed for the unittesting environment. True.

Working on this now. Unfortunately it's not being as simple as changing one line. Some tests are failing. I will send a PR after I fix everything.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iamareebjamal picture iamareebjamal  路  4Comments

Masquerade0097 picture Masquerade0097  路  3Comments

SaptakS picture SaptakS  路  3Comments

mariobehling picture mariobehling  路  4Comments

aviaryan picture aviaryan  路  3Comments