I've added ( on the develop branch ) a new base class for tests that should simplify database and library construction a lot.
It uses the test.proto.ProtoLibrary to create Sqlite and Postgres Libraries. The class can build a set of bundles and store them in either a Sqlite database, or Postgres template, so a populated library can be constructed very quickly. It also does not use the user's config file, so There is less chance of screwing up a real library.
In tests, the library should be created using TestBase.library(). WIth use_proto=False, it will return a new, unpopulated library. The postgres DSN is set with an env var, ABRY_TEST_DB, as before.
1) Clear out all of the database and library construction code from other tests, and convert them all to use this library.
Some of the code to remove:
TestBase.get_rc
TestBase.tearDown(). The test database should not be deleted on exit; instead, it should be cleared at the start. This allows inspection of the database and library after a failed test.
_create_postgres_test_db in TestBase.setUp
All database setup in TestBase.setUpClass
I used test_base.PostgreSQLTestBase for a lot of the code in ProtoLibrary, so it should not be necessary any more.
Then, fix the Warehouse tests to use the new system.
I've added ( on the develop branch ) a new base class for tests that should simplify database and library construction a lot.
It uses the test.proto.ProtoLibrary to create Sqlite and Postgres Libraries. The class can build a set of bundles and store them in either a Sqlite database, or Postgres template, so a populated library can be constructed very quickly. It also does not use the user's config file, so There is less chance of screwing up a real library.
In tests, the library should be created using TestBase.library(). WIth use_proto=False, it will return a new, unpopulated library. The postgres DSN is set with an env var, ABRY_TEST_DB, as before.
1) Clear out all of the database and library construction code from other tests, and convert them all to use this library.
Some of the code to remove:
I used test_base.PostgreSQLTestBase for a lot of the code in ProtoLibrary, so it should not be necessary any more.
Then, fix the Warehouse tests to use the new system.