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))
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)
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)
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)
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')
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")
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)
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')
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)
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)
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)
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')
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)
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)
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)
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)
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' )
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, )
def test_port(self): self.option_values.port = 7890 mllp_send() self.mock_socket().connect.assert_called_once_with(('localhost', 7890))