def test_get_usage_template_ok(get_mock): get_mock.side_effect = [ Response(ok=True, text='{"template_link": "..."}', status_code=200), BinaryResponse(ok=True, content=b'template_contents', status_code=200)] resource = UsageAutomation() assert resource.get_usage_template(Product(id='PRD-638-321-603')) == b'template_contents' get_mock.assert_has_calls([ call( url='http://localhost:8080/api/public/v1/usage/products/PRD-638-321-603/template/', headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300), call('...') ])
def test_get_usage_template_no_file(): resource = UsageAutomation() with pytest.raises(FileRetrievalError): resource.get_usage_template(Product(id='PRD-638-321-603'))
def test_create_resource(): requests = UsageAutomation().list() assert isinstance(requests, list) assert len(requests) == 8