예제 #1
0
    def test_version(self):
        self.option_values.version = True

        mllp_send()

        self.assertFalse(self.mock_socket().connect.called)
        self.mock_stdout.assert_called_once_with(str(hl7_version))
예제 #2
0
    def test_quiet(self):
        self.option_values.verbose = False

        mllp_send()

        self.mock_socket().send.assert_called_once_with(SB + b"foobar" + EB + CR)
        self.assertFalse(self.mock_stdout.called)
예제 #3
0
    def test_stdin(self):
        self.option_values.filename = None
        self.mock_stdin.return_value = FakeStream()

        mllp_send()

        self.mock_socket().send.assert_called_once_with(SB + 'hello' + EB + CR)
예제 #4
0
    def test_quiet(self):
        self.option_values.verbose = False

        mllp_send()

        self.mock_socket().send.assert_called_once_with(SB + 'foobar' + EB + CR)
        self.assertFalse(self.mock_stdout.called)
예제 #5
0
    def test_version(self):
        self.option_values.version = True

        mllp_send()

        self.assertFalse(self.mock_socket().connect.called)
        self.mock_stdout.assert_called_once_with(str(hl7_version))
예제 #6
0
    def test_send(self):
        mllp_send()

        self.mock_socket().connect.assert_called_once_with(('localhost', 6661))
        self.mock_socket().send.assert_called_once_with(SB + b'foobar' + EB +
                                                        CR)
        self.mock_stdout.assert_called_once_with('thanks')
예제 #7
0
    def test_send(self):
        mllp_send()

        self.mock_socket().connect.assert_called_once_with(("localhost", 6661))
        self.mock_socket().send.assert_called_once_with(SB + b"foobar" + EB +
                                                        CR)
        self.mock_stdout.assert_called_once_with("thanks")
예제 #8
0
    def test_stdin(self):
        self.option_values.filename = None
        self.mock_stdin.return_value = FakeStream()

        mllp_send()

        self.mock_socket().send.assert_called_once_with(SB + b'hello' + EB + CR)
예제 #9
0
    def test_send(self):
        mllp_send()

        self.mock_socket().connect.assert_called_once_with(('localhost', 6661))
        self.mock_socket().send.assert_called_once_with(
            SB + b'foobar' + EB + CR
        )
        self.mock_stdout.assert_called_once_with('thanks')
예제 #10
0
    def test_loose_no_mllp_characters(self):
        self.option_values.loose = True
        self.write('MSH|^~\&|foo\r\nbar\r\n')

        mllp_send()

        self.mock_socket().send.assert_called_once_with(SB + 'MSH|^~\&|foo\rbar'
                                                        + EB + CR)
예제 #11
0
    def test_loose_unix_newline(self):
        self.option_values.loose = True
        self.write(SB + 'MSH|^~\&|foo\nbar\n' + EB + CR)

        mllp_send()

        self.mock_socket().send.assert_called_once_with(SB + 'MSH|^~\&|foo\rbar'
                                                        + EB + CR)
예제 #12
0
    def test_loose_windows_newline(self):
        self.option_values.loose = True
        self.write(SB + b"MSH|^~\\&|foo\r\nbar\r\n" + EB + CR)

        mllp_send()

        self.mock_socket().send.assert_called_once_with(SB +
                                                        b"MSH|^~\\&|foo\rbar" +
                                                        EB + CR)
예제 #13
0
    def test_loose_no_stdin(self):
        self.option_values.loose = True
        self.option_values.filename = None
        self.mock_stdin.return_value = FakeStream()

        mllp_send()

        self.assertFalse(self.mock_socket().send.called)
        self.mock_stderr().write.assert_call_with('--loose requires --file\n')
예제 #14
0
    def test_loose_no_mllp_characters(self):
        self.option_values.loose = True
        self.write(b'MSH|^~\&|foo\r\nbar\r\n')

        mllp_send()

        self.mock_socket().send.assert_called_once_with(SB +
                                                        b'MSH|^~\&|foo\rbar' +
                                                        EB + CR)
예제 #15
0
    def test_loose_unix_newline(self):
        self.option_values.loose = True
        self.write(SB + b'MSH|^~\&|foo\nbar\n' + EB + CR)

        mllp_send()

        self.mock_socket().send.assert_called_once_with(SB +
                                                        b'MSH|^~\&|foo\rbar' +
                                                        EB + CR)
예제 #16
0
    def test_send_multiple(self):
        self.mock_socket().recv.return_value = 'thanks'
        self.write(SB + b'foobar' + EB + CR + SB + b'hello' + EB + CR)

        mllp_send()

        self.assertEqual(self.mock_socket().send.call_args_list[0][0][0],
                         SB + b'foobar' + EB + CR)
        self.assertEqual(self.mock_socket().send.call_args_list[1][0][0],
                         SB + b'hello' + EB + CR)
예제 #17
0
    def test_send_multiple(self):
        self.mock_socket().recv.return_value = 'thanks'
        self.write(SB + b'foobar' + EB + CR + SB + b'hello' + EB + CR)

        mllp_send()

        self.assertEqual(self.mock_socket().send.call_args_list[0][0][0],
                         SB + b'foobar' + EB + CR)
        self.assertEqual(self.mock_socket().send.call_args_list[1][0][0],
                         SB + b'hello' + EB + CR)
예제 #18
0
    def test_loose_send_mutliple(self):
        self.option_values.loose = True
        self.mock_socket().recv.return_value = 'thanks'
        self.write(b'MSH|^~\&|1\r\nOBX|1\r\nMSH|^~\&|2\r\nOBX|2\r\n')

        mllp_send()

        self.assertEqual(self.mock_socket().send.call_args_list[0][0][0],
                         SB + b'MSH|^~\&|1\rOBX|1' + EB + CR)
        self.assertEqual(self.mock_socket().send.call_args_list[1][0][0],
                         SB + b'MSH|^~\&|2\rOBX|2' + EB + CR)
예제 #19
0
    def test_loose_send_mutliple(self):
        self.option_values.loose = True
        self.mock_socket().recv.return_value = 'thanks'
        self.write(b'MSH|^~\&|1\r\nOBX|1\r\nMSH|^~\&|2\r\nOBX|2\r\n')

        mllp_send()

        self.assertEqual(self.mock_socket().send.call_args_list[0][0][0],
                         SB + b'MSH|^~\&|1\rOBX|1' + EB + CR)
        self.assertEqual(self.mock_socket().send.call_args_list[1][0][0],
                         SB + b'MSH|^~\&|2\rOBX|2' + EB + CR)
예제 #20
0
    def test_loose_no_stdin(self):
        self.option_values.loose = True
        self.option_values.filename = None
        self.mock_stdin.return_value = FakeStream()

        mllp_send()

        self.assertFalse(self.mock_socket().send.called)
        self.mock_stderr().write.assert_call_with(
            '--loose requires --file\n'
        )
예제 #21
0
    def test_loose_send_mutliple(self):
        self.option_values.loose = True
        self.mock_socket().recv.return_value = "thanks"
        self.write(b"MSH|^~\\&|1\r\nOBX|1\r\nMSH|^~\\&|2\r\nOBX|2\r\n")

        mllp_send()

        self.assertEqual(
            self.mock_socket().send.call_args_list[0][0][0],
            SB + b"MSH|^~\\&|1\rOBX|1" + EB + CR,
        )
        self.assertEqual(
            self.mock_socket().send.call_args_list[1][0][0],
            SB + b"MSH|^~\\&|2\rOBX|2" + EB + CR,
        )
예제 #22
0
    def test_port(self):
        self.option_values.port = 7890

        mllp_send()

        self.mock_socket().connect.assert_called_once_with(('localhost', 7890))
예제 #23
0
    def test_port(self):
        self.option_values.port = 7890

        mllp_send()

        self.mock_socket().connect.assert_called_once_with(('localhost', 7890))