示例#1
0
    def test_don_quixote_dictionary(self):
        archive_file, output_file = gen_archive_output_pair(
            'don_quixote_dictionary')

        don = DonQuixote(
            blueprints={"blueprints": [
                {
                    "service": "cli_emitter",
                    "args": "-f "
                            "test_data/inputs/don_quixote_dictionary._input"
                            " --output_sock_url tcp://*:9997 -d 0"
                },
                {
                    "service": "cli_listener",
                    "args": "-f "
                            "test_out/don_quixote_dictionary._output"
                            " --input_sock_url tcp://localhost:9997"
                }
            ]},
            disable_keyboard=True)
        assert don

        t = Thread(target=don.run)
        t.start()
        time.sleep(2)
        assert t.is_alive()
        don.kill()
        t.join(2)
        assert not t.is_alive()

        self.assertFiles(archive_file, output_file)
示例#2
0
    def test_don_quixote_dictionary(self):
        archive_file, output_file = gen_archive_output_pair(
            'don_quixote_dictionary')

        don = DonQuixote(blueprints={
            "blueprints": [{
                "service":
                "cli_emitter",
                "args":
                "-f "
                "test_data/inputs/don_quixote_dictionary._input"
                " --output_sock_url tcp://*:9997 -d 0"
            }, {
                "service":
                "cli_listener",
                "args":
                "-f "
                "test_out/don_quixote_dictionary._output"
                " --input_sock_url tcp://localhost:9997"
            }]
        },
                         disable_keyboard=True)
        assert don

        t = Thread(target=don.run)
        t.start()
        time.sleep(2)
        assert t.is_alive()
        don.kill()
        t.join(2)
        assert not t.is_alive()

        self.assertFiles(archive_file, output_file)
示例#3
0
    def test_cli_listener_file_option(self):
        archive_file, output_file = gen_archive_output_pair(
            'cli_listener_file_option')

        args = ['-f', output_file]
        self._deliver_the_message('Goodbye, Yesterday', args)

        self.assertFiles(archive_file, output_file)
    def test_cli_listener_file_option(self):
        archive_file, output_file = gen_archive_output_pair(
            'cli_listener_file_option')

        args = ['-f', output_file]
        self._deliver_the_message('Goodbye, Yesterday', args)

        self.assertFiles(archive_file, output_file)
示例#5
0
    def test_cli_socket_type_option(self):
        archive_file, output_file = gen_archive_output_pair(
            'cli_socket_type_option')

        args = [
            '-f', output_file, '--input_sock_type', 'SUB',
            '--input_sock_filter', 'cat', '--input_sock_url',
            'tcp://localhost:6679'
        ]

        self._deliver_the_messages([
            'throw away\n', 'dog house\n', 'cat people\n', 'dog nap\n',
            'cat scratch\n'
        ], args, 'PUB')

        self.assertFiles(archive_file, output_file)
示例#6
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)
示例#7
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)
    def test_cli_socket_type_option(self):
        archive_file, output_file = gen_archive_output_pair(
            'cli_socket_type_option')

        args = ['-f', output_file,
                '--input_sock_type', 'SUB',
                '--input_sock_filter', 'cat',
                '--input_sock_url', 'tcp://localhost:6679']

        self._deliver_the_messages(['throw away\n',
                                    'dog house\n',
                                    'cat people\n',
                                    'dog nap\n',
                                    'cat scratch\n'],
                                   args, 'PUB')

        self.assertFiles(archive_file, output_file)
示例#9
0
    def test_don_quixote_file(self):
        archive_file, output_file = gen_archive_output_pair('don_quixote_file')

        don = DonQuixote(
            file='test_data/blueprints/don_quixote_file.blueprint',
            disable_keyboard=True)
        assert don

        t = Thread(target=don.run)
        t.start()
        time.sleep(2)
        assert t.is_alive()
        don.kill()
        t.join(3)
        assert not t.is_alive()

        self.assertFiles(archive_file, output_file)
示例#10
0
    def test_don_quixote_file(self):
        archive_file, output_file = gen_archive_output_pair(
            'don_quixote_file')

        don = DonQuixote(
            file='test_data/blueprints/don_quixote_file.blueprint',
            disable_keyboard=True)
        assert don

        t = Thread(target=don.run)
        t.start()
        time.sleep(2)
        assert t.is_alive()
        don.kill()
        t.join(3)
        assert not t.is_alive()

        self.assertFiles(archive_file, output_file)
示例#11
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)
示例#12
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)