# Path: oppy/cell/definitions.py
# CREATE2_CMD         = 10
# 
# PADDING_CMD         = 0
# 
# VPADDING_CMD        = 128
# 
# Path: oppy/connection/connection.py
# class Connection(Protocol):
#     def __init__(self, connection_manager, connection_task):
#     def send(self, cell):
#     def dataReceived(self, data):
#     def _recv(self, cell):
#     def addCircuit(self, circuit):
#     def closeConnection(self):
#     def connectionLost(self, reason):
#     def _destroyAllCircuits(self):
#     def removeCircuit(self, circuit):


import mock
from twisted.trial import unittest
from oppy.cell.definitions import (
    CREATE2_CMD,
    PADDING_CMD,
    VPADDING_CMD,
)
from oppy.connection import connection
        self.connection.transport.write = mock.Mock()

        mock_cell = mock.Mock()
        mock_cell.get_bytes = mock.Mock()

        self.connection.send(mock_cell)

        self.connection.transport.write.assert_called_once_with(
                                                         mock_cell.getBytes())

    # TODO: test dataReceived

    def test_recv_no_padding_have_circuit(self):
        mock_cell = mock.Mock()
        mock_cell.header = mock.Mock()
        mock_cell.header.circ_id = 0
        mock_cell.header.cmd = CREATE2_CMD
        mock_circuit = mock.Mock()
        mock_circuit.recv = mock.Mock()

        self.connection._circuit_dict[0] = mock_circuit

        self.connection._recv(mock_cell)

        mock_circuit.recv.assert_called_once_with(mock_cell)

    def test_recvCell_padding_fixed(self):
        mock_cell = mock.Mock()
        mock_cell.header = mock.Mock()
        mock_cell.header.circ_id = 0

# Path: oppy/cell/definitions.py
# CREATE2_CMD         = 10
# 
# PADDING_CMD         = 0
# 
# VPADDING_CMD        = 128
# 
# Path: oppy/connection/connection.py
# class Connection(Protocol):
#     def __init__(self, connection_manager, connection_task):
#     def send(self, cell):
#     def dataReceived(self, data):
#     def _recv(self, cell):
#     def addCircuit(self, circuit):
#     def closeConnection(self):
#     def connectionLost(self, reason):
#     def _destroyAllCircuits(self):
#     def removeCircuit(self, circuit):


# Path: oppy/tests/unit/connection/test_connection.py
import mock
from twisted.trial import unittest
from oppy.cell.definitions import (
    CREATE2_CMD,
    PADDING_CMD,
    VPADDING_CMD,
)
from oppy.connection import connection

        self.connection.transport.write = mock.Mock()

        mock_cell = mock.Mock()
        mock_cell.get_bytes = mock.Mock()

        self.connection.send(mock_cell)

        self.connection.transport.write.assert_called_once_with(
                                                         mock_cell.getBytes())

    # TODO: test dataReceived

    def test_recv_no_padding_have_circuit(self):
        mock_cell = mock.Mock()
        mock_cell.header = mock.Mock()
        mock_cell.header.circ_id = 0
        mock_cell.header.cmd = CREATE2_CMD
        mock_circuit = mock.Mock()
        mock_circuit.recv = mock.Mock()

        self.connection._circuit_dict[0] = mock_circuit

        self.connection._recv(mock_cell)

        mock_circuit.recv.assert_called_once_with(mock_cell)

    def test_recvCell_padding_fixed(self):
        mock_cell = mock.Mock()
        mock_cell.header = mock.Mock()
        mock_cell.header.circ_id = 0

        mock_cell.header.cmd = PADDING_CMD