Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. def mocked_fetch_url(*args, **kwargs):
  2.     if args[0] == 'https://api.meraki.com/404':
  3.         info = {'status': 404,
  4.                 'body': "404 - Page is missing",
  5.                 }
  6.     return (None, info)
  7.  
  8.  
  9. @mock.patch('ansible.module_utils.urls.fetch_url', spec=mocked_fetch_url)
  10. def test_fetch_url_404(module, mocker):
  11.     url = 'https://api.meraki.com/404'
  12.     data = module.request(url, method='GET')
  13.     print(data)
  14.     assert module.status == 404
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement