Example #1
0
def run_tests(TestCase):
    '''
    Run integration tests for a chosen test case.

    Function uses optparse to set up test environment
    '''
    from saltunittest import TestLoader, TextTestRunner
    opts = parse_opts()
    loader = TestLoader()
    tests = loader.loadTestsFromTestCase(TestCase)
    print('Setting up Salt daemons to execute tests')
    with TestDaemon(clean=opts.clean):
        runner = TextTestRunner(verbosity=opts.verbosity).run(tests)
        sys.exit(runner.wasSuccessful())
Example #2
0
        me = event.MinionEvent(**opts)
        self.assertEqual(
            me.puburi, 'ipc://{0}'.format(
                os.path.join(SOCK_DIR, 'minion_event_foo_pub.ipc')))
        self.assertEqual(
            me.pulluri, 'ipc://{0}'.format(
                os.path.join(SOCK_DIR, 'minion_event_foo_pull.ipc')))

    def test_minion_event_tcp_ipc_mode(self):
        opts = dict(id='foo', ipc_mode='tcp')
        me = event.MinionEvent(**opts)
        self.assertEqual(me.puburi, 'tcp://127.0.0.1:4510')
        self.assertEqual(me.pulluri, 'tcp://127.0.0.1:4511')

    def test_minion_event_no_id(self):
        me = event.MinionEvent(sock_dir=SOCK_DIR)
        self.assertEqual(
            me.puburi,
            'ipc://{0}'.format(os.path.join(SOCK_DIR,
                                            'minion_event__pub.ipc')))
        self.assertEqual(
            me.pulluri,
            'ipc://{0}'.format(os.path.join(SOCK_DIR,
                                            'minion_event__pull.ipc')))


if __name__ == "__main__":
    loader = TestLoader()
    tests = loader.loadTestsFromTestCase(TestSaltEvent)
    TextTestRunner(verbosity=1).run(tests)