Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help3403


This forum is provided to promote discussion amongst students enrolled in Agile Web Development (CITS3403).
 
Options:
RSS cloud
Jump to:

Unit Tests

2 of 419 articles shown, currently no other people reading this forum.
photo
From: Pallavi V.
Date: Tue 19th May 2020, 12:36am
Actions: 
        Login-to-reply

 

Hi,

I am getting a bit confused in how to create a test database.

Do we need to delete our migrations folder and app.db for our existing project in 
order to initialize a test database?

Will the db initialization create app.db again?

Thanks

Unit Tests

photo
From: Timothy F.
Date: Tue 19th May 2020, 9:30am
Actions: 
        Login-to-reply

 

"Pallavi Verma" <22*0*7*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> Hi,
> 
> I am getting a bit confused in how to create a test database.
> 
> Do we need to delete our migrations folder and app.db for our existing project in 
> order to initialize a test database?
> 
> Will the db initialization create app.db again?
> 
> Thanks

You shouldn't need to remove the app database. You just need to create a new Testing 
configuration pointing to the test database. I wnet through this in the Testing 
workshop. I did need to remove the migrations etc when I set up migrations for the 
test database, but this was a mistake. The test database shouldn't need any 
migrations as it is built just to run the tests. (Migrations are for persistent 
datastores).

Then the db init should just create test.db (if that's what you had in your confug 
file) 

You can also set up an in-memory sqlite database;
https://realpython.com/python-web-applications-with-flask-part-iii/
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  2:34pm Sep 18 2020