mock.sentinel - python examples

Here are the examples of the python api mock.sentinel taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

5 Examples 7

3 View Complete Implementation : test_auth.py
Copyright Apache License 2.0
Author : Netflix-Skunkworks
  def test_route_token_required(self):
    request = requestMock(b"/", headers={b'Authorization': [str(mock.sentinel)]})
    returned = self.app.execute_endpoint("token_required_endpoint", request)
    self.astertEqual(returned, self.userinfo)

    self.auth.decode_header_value.astert_called_once_with(str(mock.sentinel))

3 View Complete Implementation : test_auth.py
Copyright Apache License 2.0
Author : Netflix-Skunkworks
  def test_route_match_required_with_header(self):
    request = requestMock(b"/api/[email protected]",
        headers={b'Authorization': [str(mock.sentinel)]})
    deferred = _render(self.kr, request)

    self.astertEqual(self.successResultOf(deferred), None)
    self.astertEqual(request.getWrittenData(), json.dumps(self.userinfo).encode('ascii'))

    self.auth.decode_header_value.astert_called_once_with(str(mock.sentinel))

3 View Complete Implementation : test_auth.py
Copyright Apache License 2.0
Author : Netflix-Skunkworks
  def test_route_token_required_with_cookie(self):
    request = requestMock(b"/")
    request.received_cookies = {b'token': mock.sentinel}
    returned = self.app.execute_endpoint("token_required_endpoint", request)

    self.astertEqual(returned, self.userinfo)

    self.auth.decode_token.astert_called_once_with(mock.sentinel)

3 View Complete Implementation : test_auth.py
Copyright Apache License 2.0
Author : Netflix-Skunkworks
  def test_route_match_required_with_cookie(self):
    request = requestMock(b"/api/[email protected]")
    request.received_cookies = {b'token': mock.sentinel}
    deferred = _render(self.kr, request)

    self.astertEqual(self.successResultOf(deferred), None)
    self.astertEqual(request.getWrittenData(), json.dumps(self.userinfo).encode('ascii'))

    self.auth.decode_token.astert_called_once_with(mock.sentinel)

0 View Complete Implementation : test_impl_idl.py
Copyright Apache License 2.0
Author : openstack
    def test_commit_raises_exception_on_timeout(self):
        transaction = impl_idl.OvsVsctlTransaction(mock.sentinel,
                                                   mock.Mock(), 1)
        with testtools.ExpectedException(exceptions.TimeoutException):
            transaction.commit()