def test_dump_non_psql_driver(self): with self.assertRaises(SystemExit) as cm: config = SimpleNamespace() config.database = {'database_driver': 'sqlite'} args = Namespace() args.config = config dump(args) self.assertEqual(str(cm.exception), 'Cannot dump schema for non-postgresql database')
def test_dump_course(self, subprocess): with TemporaryDirectory() as tmp_dirname: config = SimpleNamespace() config.database = {'database_driver': 'psql'} args = Namespace() args.config = config args.environments = ['course'] args.path = tmp_dirname data_dir = Path(tmp_dirname, 'data') data_dir.mkdir() dump(args) course_db = data_dir / 'course_tables.sql' self.assertTrue(course_db.exists()) self.assertEqual(COURSE_DB_EXPECTED, course_db.read_text()) self.assertRegex( sys.stdout.getvalue(), r"Dumping course environment to .*/data/course_tables.sql... DONE" )