From 4caed6184cfc760aab35084bdc7c6a6aa8dd486c Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Sat, 30 Jan 2016 17:17:23 -0500 Subject: [PATCH 1/2] Do not flush the database when using bok-choy in testsonly mode. Testsonly will not work currently, because the database flush will remove some data fixtures. Even when they are loaded at the beginning of the next test run, there are database corruptions. Instead of flushing, do not do anything with the database at the end of the testsonly test run. That way, tests that use dynamic data can be run many times in a row. --- pavelib/utils/test/suites/bokchoy_suite.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pavelib/utils/test/suites/bokchoy_suite.py b/pavelib/utils/test/suites/bokchoy_suite.py index 3500d4f0d6..82a3b59538 100644 --- a/pavelib/utils/test/suites/bokchoy_suite.py +++ b/pavelib/utils/test/suites/bokchoy_suite.py @@ -104,7 +104,10 @@ class BokChoyTestSuite(TestSuite): print msg # Clean up data we created in the databases - sh("./manage.py lms --settings bok_choy flush --traceback --noinput") + if not self.testsonly: + # Using testsonly will leave all fixtures in place (Note: the db will also be dirtier.) + sh("./manage.py lms --settings bok_choy flush --traceback --noinput") + bokchoy_utils.clear_mongo() def verbosity_processes_string(self): From e5da5006fb9f9caf8d5f78db93b19096b4dc1fb6 Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Tue, 2 Feb 2016 11:36:13 -0500 Subject: [PATCH 2/2] Testsonly mode should also skip clearing mongo. --- pavelib/utils/test/suites/bokchoy_suite.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pavelib/utils/test/suites/bokchoy_suite.py b/pavelib/utils/test/suites/bokchoy_suite.py index 82a3b59538..9553d83805 100644 --- a/pavelib/utils/test/suites/bokchoy_suite.py +++ b/pavelib/utils/test/suites/bokchoy_suite.py @@ -100,15 +100,16 @@ class BokChoyTestSuite(TestSuite): def __exit__(self, exc_type, exc_value, traceback): super(BokChoyTestSuite, self).__exit__(exc_type, exc_value, traceback) - msg = colorize('green', "Cleaning up databases...") - print msg - - # Clean up data we created in the databases - if not self.testsonly: - # Using testsonly will leave all fixtures in place (Note: the db will also be dirtier.) + # Using testsonly will leave all fixtures in place (Note: the db will also be dirtier.) + if self.testsonly: + msg = colorize('green', 'Running in testsonly mode... SKIPPING database cleanup.') + print msg + else: + # Clean up data we created in the databases + msg = colorize('green', "Cleaning up databases...") + print msg sh("./manage.py lms --settings bok_choy flush --traceback --noinput") - - bokchoy_utils.clear_mongo() + bokchoy_utils.clear_mongo() def verbosity_processes_string(self): """