def _test_email_default_behavior(self, smtp_mock):
        #with patch('sock.SMTP', autospec=True) as mock_smtp:
        #define mock behavior
        mock_smtp_object = MagicMock()
        smtp_mock.side_effect = mock_smtp_object

        t = thread_wrap_windmill('EmailWindmill', argv=[])
        assert t

        try:
            t.start()
            self.assertTrue(t.is_alive(),
                            'The EmailWindmill instance should have started.')
            self.sock_map['PUSH'].send(
                '{"type":"email_request","payload" : {"msg" : "Hi, this is a message that has been delivered through email service as a test.\nNeeded '
                'multi '
                'recipient test.\n\n share and enjoy", "subject" : "A message from email send service.", "sender" : "*****@*****.**",'
                '"to" : ["*****@*****.**"]}}')
            time.sleep(1)
        finally:
            t.windmill.kill()
            t.join(3)
            self.assertFalse(
                t.is_alive(),
                'The EmailWindmill instance should have shut down.')
Esempio n. 2
0
    def test_conrnerstone_default_behavior(self):
        foo = Cornerstone()

        t = thread_wrap_windmill('Cornerstone', argv=None)
        t.start()
        assert t.is_alive()

        # send kill command
        kill_cornerstone()
        t.join(3)
        assert not t.is_alive()
Esempio n. 3
0
 def _deliver_the_message(self, msg=None, args=list(), sock_type='PUSH'):
     t = thread_wrap_windmill('CliListener', args)
     try:
         t.start()
         self.assertTrue(t.is_alive())
         self.sock_map[sock_type].send(msg)
         time.sleep(1)
     finally:
         t.windmill.kill()
         t.join(3)
         self.assertFalse(t.is_alive(),
                          'CliListener instance should have shutdown.')
Esempio n. 4
0
 def _deliver_the_message(self, msg=None, args=list(), sock_type='PUSH'):
     t = thread_wrap_windmill('CliListener', args)
     try:
         t.start()
         self.assertTrue(t.is_alive())
         self.sock_map[sock_type].send(msg)
         time.sleep(1)
     finally:
         t.windmill.kill()
         t.join(3)
         self.assertFalse(t.is_alive(),
                          'CliListener instance should have shutdown.')
Esempio n. 5
0
 def test_cli_listener_default_behavior(self):
     t = thread_wrap_windmill('CliListener')
     try:
         t.start()
         self.assertTrue(t.is_alive(),
                         'The CliEmitter instance should have started.')
         self.sock_map['PUSH'].send('Hello')
         time.sleep(1)
     finally:
         t.windmill.kill()
         t.join(3)
         self.assertFalse(t.is_alive(),
                          'The CliEmitter instance should have shut down.')
Esempio n. 6
0
 def test_cli_listener_default_behavior(self):
     t = thread_wrap_windmill('CliListener')
     try:
         t.start()
         self.assertTrue(t.is_alive(),
                         'The CliEmitter instance should have started.')
         self.sock_map['PUSH'].send('Hello')
         time.sleep(1)
     finally:
         t.windmill.kill()
         t.join(3)
         self.assertFalse(t.is_alive(),
                          'The CliEmitter instance should have shut down.')
Esempio n. 7
0
    def test_cli_emitter_default_hehaviour(self):
        archive_file, output_file = gen_archive_output_pair(
            'cli_emitter_default_behavior')

        emitter = CliEmitter()
        assert emitter

        # create the listener and direct it's output to out_file
        t = thread_wrap_windmill('CliListener', argv=[
            '-f', output_file,
            '--input_sock_url', 'tcp://localhost:6677'])
        assert t

        self.emit_message(emitter, t)

        self.assertFiles(archive_file, output_file)
Esempio n. 8
0
    def executor(self, test_name=None, emitter_args=None, listener_args=None):
        assert test_name
        archive_file, output_file = gen_archive_output_pair(test_name)

        emitter = CliEmitter(argv=emitter_args)
        assert emitter

        # add the output file to the listener arguments
        listener_args = ['-f', output_file] + listener_args
        # create the listener and direct it's output to out_file
        t = thread_wrap_windmill('CliListener', argv=listener_args)
        assert t

        self.emit_message(emitter, t)

        self.assertFiles(archive_file, output_file)
Esempio n. 9
0
    def test_cli_emitter_default_hehaviour(self):
        archive_file, output_file = gen_archive_output_pair(
            'cli_emitter_default_behavior')

        emitter = CliEmitter()
        assert emitter

        # create the listener and direct it's output to out_file
        t = thread_wrap_windmill('CliListener',
                                 argv=[
                                     '-f', output_file, '--input_sock_url',
                                     'tcp://localhost:6677'
                                 ])
        assert t

        self.emit_message(emitter, t)

        self.assertFiles(archive_file, output_file)
Esempio n. 10
0
    def executor(self,
                 test_name=None,
                 emitter_args=None,
                 listener_args=None):
        assert test_name
        archive_file, output_file = gen_archive_output_pair(test_name)

        emitter = CliEmitter(argv=emitter_args)
        assert emitter

        # add the output file to the listener arguments
        listener_args = ['-f', output_file] + listener_args
        # create the listener and direct it's output to out_file
        t = thread_wrap_windmill('CliListener', argv=listener_args)
        assert t

        self.emit_message(emitter, t)

        self.assertFiles(archive_file, output_file)
Esempio n. 11
0
    def test_echo_service_options(self):
        req_out_sock = self.zmq_ctx.socket(REQ)
        req_out_sock.bind('tcp://*:8899')

        argv = ['-m', 'pong', '--reply_sock_url', 'tcp://localhost:8899']
        t = thread_wrap_windmill('EchoService', argv=argv)
        try:
            t.start()
            self.assertTrue(t.is_alive(),
                            'The EchoService instance should have started.')
            req_out_sock.send('ping')
            msg = req_out_sock.recv()

            self.assertEqual('pong', msg)
        finally:
            t.windmill.kill()
            t.join(3)
            self.assertFalse(t.is_alive(),
                             'The EchoService instance shold have shutdown.')

            req_out_sock.close()
Esempio n. 12
0
    def test_echo_service_default_behavior(self):
        req_out_sock = self.zmq_ctx.socket(REQ)
        req_out_sock.bind('tcp://*:8889')

        t = thread_wrap_windmill('EchoService')

        try:
            t.start()
            self.assertTrue(t.is_alive,
                            'The EchoService instance should have started.')
            req_out_sock.send("echo, echo, echo")
            msg = req_out_sock.recv()

            self.assertEqual("echo, echo, echo", msg)
        finally:
            t.windmill.kill()
            t.join(3)
            self.assertFalse(t.is_alive(),
                             'The EchoService instance should have shutdown.')

            req_out_sock.close()
Esempio n. 13
0
    def _test_email_sub_behavior(self):
    #with patch('sock.SMTP', autospec=True) as mock_smtp:
        #define mock behavior
        mock_smtp_object = MagicMock()
        #smtp_mock.SMTP.side_effect = mock_smtp_object

        args = '--input_sock_url tcp://*:6679 --input_bind --input_sock_type SUB --verbose --monitor_stream'
        t = thread_wrap_windmill('EmailWindmill', argv=args.split())
        assert t

        try:
            t.start()
            self.assertTrue(t.is_alive(),
                            'The EmailWindmill instance should have started.')
            self.sock_map['PUB'].send(
                '{"type":"email_request","payload" : {"msg" : "Hi, this is a message that has been delivered through email service as a test. \\nNeeded multi recipient test. share and enjoy", "subject" : "A message from email send service.", "sender" : "*****@*****.**","to" : ["*****@*****.**"]}}')
            time.sleep(1)
        finally:
            t.windmill.kill()
            t.join(3)
            self.assertFalse(t.is_alive(),
                             'The EmailWindmill instance should have shut down.')
Esempio n. 14
0
    def _test_email_sub_behavior(self):
        #with patch('sock.SMTP', autospec=True) as mock_smtp:
        #define mock behavior
        mock_smtp_object = MagicMock()
        #smtp_mock.SMTP.side_effect = mock_smtp_object

        args = '--input_sock_url tcp://*:6679 --input_bind --input_sock_type SUB --verbose --monitor_stream'
        t = thread_wrap_windmill('EmailWindmill', argv=args.split())
        assert t

        try:
            t.start()
            self.assertTrue(t.is_alive(),
                            'The EmailWindmill instance should have started.')
            self.sock_map['PUB'].send(
                '{"type":"email_request","payload" : {"msg" : "Hi, this is a message that has been delivered through email service as a test. \\nNeeded multi recipient test. share and enjoy", "subject" : "A message from email send service.", "sender" : "*****@*****.**","to" : ["*****@*****.**"]}}'
            )
            time.sleep(1)
        finally:
            t.windmill.kill()
            t.join(3)
            self.assertFalse(
                t.is_alive(),
                'The EmailWindmill instance should have shut down.')
Esempio n. 15
0
    def _test_email_default_behavior(self, smtp_mock):
    #with patch('sock.SMTP', autospec=True) as mock_smtp:
        #define mock behavior
        mock_smtp_object = MagicMock()
        smtp_mock.side_effect = mock_smtp_object

        t = thread_wrap_windmill('EmailWindmill', argv=[])
        assert t

        try:
            t.start()
            self.assertTrue(t.is_alive(),
                            'The EmailWindmill instance should have started.')
            self.sock_map['PUSH'].send(
                '{"type":"email_request","payload" : {"msg" : "Hi, this is a message that has been delivered through email service as a test.\nNeeded '
                'multi '
                'recipient test.\n\n share and enjoy", "subject" : "A message from email send service.", "sender" : "*****@*****.**",'
                '"to" : ["*****@*****.**"]}}')
            time.sleep(1)
        finally:
            t.windmill.kill()
            t.join(3)
            self.assertFalse(t.is_alive(),
                             'The EmailWindmill instance should have shut down.')