def setUp(self): if skip_command_line_tests is True: raise unittest.SkipTest('skip_command_line_tests is set as True') self.config = SqlCreateOptions() self.stdout = sys.stdout self.capture = StringIO() sys.stdout = self.capture
class MambaAdminSqlCreateTest(unittest.TestCase): def setUp(self): self.config = SqlCreateOptions() self.stdout = sys.stdout self.capture = StringIO() sys.stdout = self.capture def tearDown(self): sys.stdout = self.stdout def test_wrong_number_of_args(self): self.assertRaises(usage.UsageError, self.config.parseOptions, ['test', 'wrong']) def test_default_options(self): self.config.parseOptions(['test']) self.assertEqual(self.config['live'], 0) self.assertEqual(self.config['dump'], 0) def test_set_options_works(self): self.config.parseOptions(['-d', 'test']) self.assertEqual(self.config['dump'], 1) def test_dump_and_live_cant_be_together(self): commons.raw_input = lambda _: '0' self.config.parseOptions(['-d', '-l', 'test']) self.assertTrue( 'What do you want to do. Dump the script or execute it?' in self.capture.getvalue()) self.assertTrue('Dump it' in self.capture.getvalue()) self.assertTrue('Execute it' in self.capture.getvalue())
class MambaAdminSqlCreateTest(unittest.TestCase): def setUp(self): self.config = SqlCreateOptions() self.stdout = sys.stdout self.capture = StringIO() sys.stdout = self.capture def tearDown(self): sys.stdout = self.stdout def test_wrong_number_of_args(self): self.assertRaises( usage.UsageError, self.config.parseOptions, ['test', 'wrong']) def test_default_options(self): self.config.parseOptions(['test']) self.assertEqual(self.config['live'], 0) self.assertEqual(self.config['dump'], 0) def test_set_options_works(self): self.config.parseOptions(['-d', 'test']) self.assertEqual(self.config['dump'], 1) def test_dump_and_live_cant_be_together(self): commons.raw_input = lambda _: '0' self.config.parseOptions(['-d', '-l', 'test']) self.assertTrue( 'What do you want to do. Dump the script or execute it?' in self.capture.getvalue() ) self.assertTrue('Dump it' in self.capture.getvalue()) self.assertTrue('Execute it' in self.capture.getvalue())
def setUp(self): self.config = SqlCreateOptions() self.stdout = sys.stdout self.capture = StringIO() sys.stdout = self.capture