Пример #1
0
    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
Пример #2
0
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())
Пример #3
0
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())
Пример #4
0
 def setUp(self):
     self.config = SqlCreateOptions()
     self.stdout = sys.stdout
     self.capture = StringIO()
     sys.stdout = self.capture
Пример #5
0
 def setUp(self):
     self.config = SqlCreateOptions()
     self.stdout = sys.stdout
     self.capture = StringIO()
     sys.stdout = self.capture