djngo unittest to use "real" database.

31 views
Skip to first unread message

django-newbie

unread,
Sep 7, 2020, 1:27:27 AM9/7/20
to Django users
Hi All,

I am currently writing test cases for views, Which eventually uses database also.
By default a test database is being created and removed after test are run.

As the database itself is development database, I don't want my test to create a separate db but use exciting only.
Also I will like to bring to your notice, that in my environment, database are created and provided and django can't run migration or create database.

Regards,
Arjit 

Mike Dewhirst

unread,
Sep 7, 2020, 2:34:08 AM9/7/20
to django...@googlegroups.com
On 7/09/2020 3:27 pm, django-newbie wrote:
> Hi All,
>
> I am currently writing test cases for views, Which eventually uses
> database also.
> By default a test database is being created and removed after test are
> run.

A refreshed database is most likely what you want for testing. There are
ways of retaining the test database between tests but I never do that.
On the rare occasion I want it to "persist" I run a number of assertions
in the same test. Much easier.

>
> As the database itself is development database, I don't want my test
> to create a separate db but use exciting only.

You will need to dump existing data into fixtures and load that for testing

> Also I will like to bring to your notice, that in my environment,
> database are created and provided and django can't run migration or
> create database.

Maybe you should relocate your development work to a friendlier
environment and figure out a mechanism for deploying changes back to the
production environment.

Otherwise approach your sysadmin and ask for the appropriate resourcing.

Good luck

>
> Regards,
> Arjit 
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e6fd0155-ee4e-46f7-8e81-74983d388536n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e6fd0155-ee4e-46f7-8e81-74983d388536n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.


signature.asc
Reply all
Reply to author
Forward
0 new messages