Esempio n. 1
0
def test_get(get_method):
  response = fudge.Fake('Response')
  response.provides('json').returns({'qux': 'quux'})

  get_method.expects_call().with_args(
    'https://flying-sphinx.com/api/my/app/path',
    params = {'id': '55'}, headers = {
      'Accept':                  'application/vnd.flying-sphinx-v3+json',
      'X-Flying-Sphinx-Token':   'abc:123',
      'X-Flying-Sphinx-Version': ('%s+python' % __version__)
    }
  ).returns(response)

  api = API('abc', '123')
  api.get('path', {'id': '55'})
Esempio n. 2
0
def test_get_response(get_method):
  response = fudge.Fake('Response')
  response.provides('json').returns({'qux': 'quux'})
  get_method.is_callable().calls(lambda uri, **kwargs: response)

  api = API('abc', '123')

  assert api.get('path') == {'qux': 'quux'}