diff options
author | Azul <azul@leap.se> | 2014-04-16 11:14:55 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-04-17 10:39:59 +0200 |
commit | 0f0057e65c6bfcb98ce53e1a48aa1460d3a6716a (patch) | |
tree | 012b992f23713788ac2e4474266f95d2c33df144 /test/nagios/support/api.py | |
parent | 73bdb9a9ea8932e9a14f996391d348690da1a63c (diff) |
move support classes into their own package
now the webapp_login test looks nice and clean. soledad next.
Diffstat (limited to 'test/nagios/support/api.py')
-rw-r--r-- | test/nagios/support/api.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/nagios/support/api.py b/test/nagios/support/api.py new file mode 100644 index 0000000..3b6a90f --- /dev/null +++ b/test/nagios/support/api.py @@ -0,0 +1,33 @@ +import requests +import json + +class Api(): + def __init__(self, config, verify=True): + self.config = config.api + self.session = requests.session() + self.verify = verify + + def api_url(self, path): + return self.api_root() + path + + def api_root(self): + return "https://{domain}:{port}/{version}/".format(**self.config) + + def get(self, path, **args): + response = self.session.get(self.api_url(path), + verify=self.verify, + **args) + return response.json() + + def post(self, path, **args): + response = self.session.post(self.api_url(path), + verify=self.verify, + **args) + return response.json() + + def put(self, path, **args): + response = self.session.put(self.api_url(path), + verify=self.verify, + **args) + return response.json() + |