mardi 22 mai 2018

Django with MS SQL Backend and Testing

Working on a project that ties into 2 databases that are based on MS SQL Server. These other DB's are the backbones to 2 other applications that I did not create and are not Django based. My application reads from those databases to get information for my application.

I'm writing tests for my application - but the database user for my application does not have create rights for these MS SQL databases - so it cannot create any kind of test_ tables when running tests.

What is the best way to handle that?

My Thoughts:

Idea 1: My initial thoughts were create a staging_ version of both MS SQL db's and create a user that has create rights to those databases so it can create the test_ tables, but I don't want to go bugging the DB admins to do that stuff if it doesn't work that way. I figured this route we could run tests and dev with --settings="staging_settings" and production with --settings="production_settings"

Idea 2: Figure out how to dumpdata from those 2 db's into 2 large fixtures and try to recreate them in a local SQLite db for testing purposes only. The problems with this method is that I figure because of the inherent differences between the two I'd run into some big errors (not to mention I don't know how to dumpdata for databases that aren't managed directly by Django).

I'm just really looking for how best to streamline this so I can write tests that will work without having to jump through a billion hoops to achieve this.

Aucun commentaire:

Enregistrer un commentaire