def test_receive_Cutoff_Exception(self):
        with mock.patch(
                'uhppote_rfid.controller_socket.socket') as mock_socket:
            mockSocket = ControllerSocket('127.0.0.1')
            mockSocket.socket.recv.return_value = ''

            mockSocket.connect()

            with self.assertRaises(SocketTransmitException):
                mockSocket.receive()
    def test_receive_SetLength_Valid(self):
        data = bytearray([1, 2, 3, 4, 5, 6, 7, 8])

        with mock.patch(
                'uhppote_rfid.controller_socket.socket') as mock_socket:
            mockSocket = ControllerSocket('127.0.0.1')
            mockSocket.socket.recv.return_value = data

            mockSocket.connect()
            self.assertEquals(mockSocket.receive(len(data)), data)
    def test_receive_DefaultLength_Valid(self):
        arr = [1, 2, 3, 4, 5, 6, 7, 8]

        with mock.patch(
                'uhppote_rfid.controller_socket.socket') as mock_socket:
            mockSocket = ControllerSocket('127.0.0.1')
            mockSocket.socket.recv.return_value = bytearray(arr)

            data = bytearray()
            for i in range(0, 8):
                data.extend(arr)

            mockSocket.connect()
            self.assertEquals(mockSocket.receive(), data)