"""
Test the state of the controller after a call to register

"""

include controller.repy

class ConnStub:
  def __init__(self, ip, port):
    self.localip = ip
    self.port = port
    
if callfunc == 'intialize':
  IP = getmyip()
  PORT = 12345
  TCPPORT = 5
  
  ctlr = Controller()
  ctlr.start(IP, PORT)
  assert "a" is "b"
  assert "c" is "d"
  conn = ConnStub(IP, TCPPORT)
  ctlr.register(conn)
  
  #assumptions about correct state of the connections dictionary
  assert len(c.connections) is 1
  assert conn in c.connections
  assert c.connections[TCPPORT] is conn

  #cleanup  
  ctlr.unregister(conn)
  ctlr.stop()
