Exemplo n.º 1
0
  def test_default(self, init):
    m = MemoryStorage()
    m._store = MagicMock()
    m._store.cancer = MagicMock(return_value="data")
    m.cancer_socket = MagicMock()
    m.cancer_socket.send_pyobj = MagicMock(side_effect=KeyboardInterrupt)

    try:
      m._handle_cancer_request()
    except KeyboardInterrupt:
      # the mock raises an exception to get out of the infinite loop
      pass

    # we should be listening for requests
    m.cancer_socket.recv.assert_called_once_with()

    # we should get data from the store
    m._store.cancer.assert_called_once_with()

    # we should respond to the request with the data we got
    m.cancer_socket.send_pyobj.assert_called_once_with("data")
Exemplo n.º 2
0
    def test_default(self, init):
        m = MemoryStorage()
        m._store = MagicMock()
        m._store.cancer = MagicMock(return_value="data")
        m.cancer_socket = MagicMock()
        m.cancer_socket.send_pyobj = MagicMock(side_effect=KeyboardInterrupt)

        try:
            m._handle_cancer_request()
        except KeyboardInterrupt:
            # the mock raises an exception to get out of the infinite loop
            pass

        # we should be listening for requests
        m.cancer_socket.recv.assert_called_once_with()

        # we should get data from the store
        m._store.cancer.assert_called_once_with()

        # we should respond to the request with the data we got
        m.cancer_socket.send_pyobj.assert_called_once_with("data")