Re: Testing with complex database setups
Bummer... I whish I could have gotten away with Django test framework but it seems that custom testrunner would be the way. Have to check my options really. On Fri, 24 May 2013 03:23:44 -0700 (PDT) akaariaiwrote: > On 23 touko, 15:09, Jani Tiainen wrote: > > Hi, > > > > I've product that uses complex setup scripts - tens of SQL scripts that > > creates tables, views, complex triggers, grants permissions and such and > > finally populates database with some pre-data. > > > > So how I should proceed with unit testing with database like that, since > > some operations rely heavily that there really exists all that > > trigger-function mess in the database? So that I don't need everytime to > > start from the scratch but from some known state of the db? > > I have some code I run my tests by the doing the following: > 1. dump schema + some data from production > 2. create test database by loading the dump. > 3. Apply any migrations I have (these are plain SQL scripts, no > South involved here) > 4. run tests using SimpleTestCase or plain unittest TestCases. > > So, I am not using Django's testing framework at all. There are two > reasons: 1. I haven't found a nice way to create the database with > custom scripts etc. loaded. 2. Django's test framework likes to flush > all data from the database. This doesn't fit my needs. > > So, I suggest that you either hack a custom test runner for Django, or > just run tests without Django's testing framework. There might exists > something reusable in the ecosystem for this use case. > > It would be nice to have something that allows easy testing this way > in Django. The problem is that once you enter complex database setups > domain it is hard to find a minimal useful feature set. > > Unfortunately I don't have anything reusable for running tests this > way, my scripts for managing the above steps are too hacky to reuse. > > - Anssi > > -- > 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+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Testing with complex database setups
On 23 touko, 15:09, Jani Tiainenwrote: > Hi, > > I've product that uses complex setup scripts - tens of SQL scripts that > creates tables, views, complex triggers, grants permissions and such and > finally populates database with some pre-data. > > So how I should proceed with unit testing with database like that, since some > operations rely heavily that there really exists all that trigger-function > mess in the database? So that I don't need everytime to start from the > scratch but from some known state of the db? I have some code I run my tests by the doing the following: 1. dump schema + some data from production 2. create test database by loading the dump. 3. Apply any migrations I have (these are plain SQL scripts, no South involved here) 4. run tests using SimpleTestCase or plain unittest TestCases. So, I am not using Django's testing framework at all. There are two reasons: 1. I haven't found a nice way to create the database with custom scripts etc. loaded. 2. Django's test framework likes to flush all data from the database. This doesn't fit my needs. So, I suggest that you either hack a custom test runner for Django, or just run tests without Django's testing framework. There might exists something reusable in the ecosystem for this use case. It would be nice to have something that allows easy testing this way in Django. The problem is that once you enter complex database setups domain it is hard to find a minimal useful feature set. Unfortunately I don't have anything reusable for running tests this way, my scripts for managing the above steps are too hacky to reuse. - Anssi -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Testing with complex database setups
Hi If I understand you correctly, you want to be able to initialise your database to a known state; https://docs.djangoproject.com/en/1.5/howto/initial-data/ is what you want I think - it also contains a link to this https://docs.djangoproject.com/en/1.5/topics/testing/overview/#topics-testing-fixtures On Thu, 23 May 2013 15:09:08 +0300 Jani Tiainenwrote: > Hi, > > I've product that uses complex setup scripts - tens of SQL scripts that > creates tables, views, complex triggers, grants permissions and such and > finally populates database with some pre-data. > > So how I should proceed with unit testing with database like that, since > some operations rely heavily that there really exists all that > trigger-function mess in the database? So that I don't need everytime to > start from the scratch but from some known state of the db? > -- Drew Ferguson AFC Commercial http://www.afccommercial.co.uk -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Testing with complex database setups
Hi, I've product that uses complex setup scripts - tens of SQL scripts that creates tables, views, complex triggers, grants permissions and such and finally populates database with some pre-data. So how I should proceed with unit testing with database like that, since some operations rely heavily that there really exists all that trigger-function mess in the database? So that I don't need everytime to start from the scratch but from some known state of the db? -- Jani Tiainen -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.