Ejemplo n.º 1
0
    def test_salt_callback(self):
        @buildout._salt_callback
        def callback1(a, b=1):
            for i in buildout.LOG.levels:
                getattr(buildout.LOG, i)('{0}bar'.format(i[0]))
            return 'foo'

        def callback2(a, b=1):
            raise Exception('foo')

        ret1 = callback1(1, b=3)
        self.assertEqual(ret1['status'], True)
        self.assertEqual(ret1['logs_by_level']['warn'], ['wbar'])
        self.assertEqual(ret1['comment'], '')
        self.assertTrue(u'' u'OUTPUT:\n' u'foo\n' u'' in ret1['outlog'])

        self.assertTrue(u'Log summary:\n' in ret1['outlog'])
        self.assertTrue(u'INFO: ibar\n'
                        u'WARN: wbar\n'
                        u'DEBUG: dbar\n'
                        u'ERROR: ebar\n' in ret1['outlog'])
        self.assertTrue('by level' in ret1['outlog_by_level'])
        self.assertEqual(ret1['out'], 'foo')
        ret2 = buildout._salt_callback(callback2)(2, b=6)
        self.assertEqual(ret2['status'], False)
        self.assertTrue(
            ret2['logs_by_level']['error'][0].startswith('Traceback'))
        self.assertTrue('We did not get any '
                        'expectable answer '
                        'from buildout' in ret2['comment'])
        self.assertEqual(ret2['out'], None)
        for l in buildout.LOG.levels:
            self.assertTrue(0 == len(buildout.LOG.by_level[l]))
Ejemplo n.º 2
0
    def test_salt_callback(self):
        @buildout._salt_callback
        def callback1(a, b=1):
            for i in buildout.LOG.levels:
                getattr(buildout.LOG, i)('{0}bar'.format(i[0]))
            return 'foo'

        def callback2(a, b=1):
            raise Exception('foo')

        # pylint: disable=invalid-sequence-index
        ret1 = callback1(1, b=3)
        # These lines are throwing pylint errors - disabling for now since we are skipping
        # these tests
        #self.assertEqual(ret1['status'], True)
        #self.assertEqual(ret1['logs_by_level']['warn'], ['wbar'])
        #self.assertEqual(ret1['comment'], '')
        # These lines are throwing pylint errors - disabling for now since we are skipping
        # these tests
        #self.assertTrue(
        #     u''
        #     u'OUTPUT:\n'
        #     u'foo\n'
        #     u''
        #    in ret1['outlog']
        #)

        # These lines are throwing pylint errors - disabling for now since we are skipping
        # these tests
        #self.assertTrue(u'Log summary:\n' in ret1['outlog'])
        # These lines are throwing pylint errors - disabling for now since we are skipping
        # these tests
        # self.assertTrue(
        #     u'INFO: ibar\n'
        #     u'WARN: wbar\n'
        #     u'DEBUG: dbar\n'
        #     u'ERROR: ebar\n'
        #    in ret1['outlog']
        #)
        # These lines are throwing pylint errors - disabling for now since we are skipping
        # these tests
        #self.assertTrue('by level' in ret1['outlog_by_level'])
        #self.assertEqual(ret1['out'], 'foo')
        ret2 = buildout._salt_callback(callback2)(2, b=6)
        self.assertEqual(ret2['status'], False)
        self.assertTrue(
            ret2['logs_by_level']['error'][0].startswith('Traceback'))
        self.assertTrue(
            'We did not get any '
            'expectable answer '
            'from buildout' in ret2['comment'])
        self.assertEqual(ret2['out'], None)
        for l in buildout.LOG.levels:
            self.assertTrue(0 == len(buildout.LOG.by_level[l]))
Ejemplo n.º 3
0
    def test_salt_callback(self):
        @buildout._salt_callback
        def callback1(a, b=1):
            for i in buildout.LOG.levels:
                getattr(buildout.LOG, i)('{0}bar'.format(i[0]))
            return 'foo'

        def callback2(a, b=1):
            raise Exception('foo')

        # pylint: disable=invalid-sequence-index
        ret1 = callback1(1, b=3)
        # These lines are throwing pylint errors - disabling for now since we are skipping
        # these tests
        #self.assertEqual(ret1['status'], True)
        #self.assertEqual(ret1['logs_by_level']['warn'], ['wbar'])
        #self.assertEqual(ret1['comment'], '')
        # These lines are throwing pylint errors - disabling for now since we are skipping
        # these tests
        #self.assertTrue(
        #     u''
        #     u'OUTPUT:\n'
        #     u'foo\n'
        #     u''
        #    in ret1['outlog']
        #)

        # These lines are throwing pylint errors - disabling for now since we are skipping
        # these tests
        #self.assertTrue(u'Log summary:\n' in ret1['outlog'])
        # These lines are throwing pylint errors - disabling for now since we are skipping
        # these tests
        # self.assertTrue(
        #     u'INFO: ibar\n'
        #     u'WARN: wbar\n'
        #     u'DEBUG: dbar\n'
        #     u'ERROR: ebar\n'
        #    in ret1['outlog']
        #)
        # These lines are throwing pylint errors - disabling for now since we are skipping
        # these tests
        #self.assertTrue('by level' in ret1['outlog_by_level'])
        #self.assertEqual(ret1['out'], 'foo')
        ret2 = buildout._salt_callback(callback2)(2, b=6)
        self.assertEqual(ret2['status'], False)
        self.assertTrue(
            ret2['logs_by_level']['error'][0].startswith('Traceback'))
        self.assertTrue(
            'We did not get any '
            'expectable answer '
            'from buildout' in ret2['comment'])
        self.assertEqual(ret2['out'], None)
        for l in buildout.LOG.levels:
            self.assertTrue(0 == len(buildout.LOG.by_level[l]))
Ejemplo n.º 4
0
    def test_salt_callback(self):
        @buildout._salt_callback
        def callback1(a, b=1):
            for i in buildout.LOG.levels:
                getattr(buildout.LOG, i)('{0}bar'.format(i[0]))
            return 'foo'

        def callback2(a, b=1):
            raise Exception('foo')

        ret1 = callback1(1, b=3)
        self.assertEqual(ret1['status'], True)
        self.assertEqual(ret1['logs_by_level']['warn'], ['wbar'])
        self.assertEqual(ret1['comment'], '')
        self.assertTrue(
            u''
            u'OUTPUT:\n'
            u'foo\n'
            u''
            in ret1['outlog']
        )

        self.assertTrue(u'Log summary:\n' in ret1['outlog'])
        self.assertTrue(
            u'\n'
            u'INFO: ibar\n'
            u'\n'
            u'WARN: wbar\n'
            u'\n'
            u'DEBUG: dbar\n'
            u'\n'
            u'ERROR: ebar\n'
            in ret1['outlog']
        )
        self.assertTrue('by level' in ret1['outlog_by_level'])
        self.assertEqual(ret1['out'], 'foo')
        ret2 = buildout._salt_callback(callback2)(2, b=6)
        self.assertEqual(ret2['status'], False)
        self.assertTrue(
            ret2['logs_by_level']['error'][0].startswith('Traceback'))
        self.assertTrue(
            'We did not get any '
            'expectable answer '
            'from buildout' in ret2['comment'])
        self.assertEqual(ret2['out'], None)
        for l in buildout.LOG.levels:
            self.assertTrue(0 == len(buildout.LOG.by_level[l]))