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

  post_method.expects_call().with_args(
    'https://flying-sphinx.com/api/my/app/start', {}, 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.post('start')
Esempio n. 2
0
def test_post_response(post_method):
  response = fudge.Fake('Response')
  response.provides('json').returns({'qux': 'quux'})
  post_method.is_callable().calls(lambda uri, params, **kwargs: response)

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

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