Ejemplo n.º 1
0
    def _get(self, url, params=None, as_json=True):
        now_ms = Utils.now_ms()

        response = requests.get(url=url,
                                params=params,
                                headers=_HEADERS,
                                timeout=self._timeout)
        log.info(f"{url} method=GET duration_ms={Utils.now_ms() - now_ms}")

        return self._response(response, as_json)
Ejemplo n.º 2
0
    def _put(self, url, payload=None, as_json=True):
        now_ms = Utils.now_ms()

        response = requests.put(url=url,
                                headers=_HEADERS,
                                json=payload,
                                timeout=self._timeout)
        log.info(f"{url} method=PUT payload={json.dumps(payload)} "
                 f"duration_ms={Utils.now_ms() - now_ms}")

        return self._response(response, as_json)
Ejemplo n.º 3
0
    def _get(self, url, params=None, as_json=True):
        now_ms = Utils.now_ms()

        response = requests.get(url,
                                params=params,
                                headers=_HEADERS,
                                timeout=self._timeout)

        get_details = {}
        get_details['url'] = url
        get_details['http_method'] = 'POST'
        get_details['http_headers'] = _HEADERS
        get_details['payload'] = params
        get_details['duration_ms'] = (self._now_ms() - now_ms)

        log.info(get_details)

        return self._response(response, as_json)
Ejemplo n.º 4
0
    def _put(self, url, payload=None, as_json=True):
        now_ms = Utils.now_ms()

        response = requests.put(url=url,
                                headers=_HEADERS,
                                json=payload,
                                timeout=self._timeout)

        put_details = {}
        put_details['url'] = url
        put_details['http_method'] = 'POST'
        put_details['http_headers'] = _HEADERS
        put_details['payload'] = payload
        put_details['duration_ms'] = (self._now_ms() - now_ms)

        log.info(put_details)

        return self._response(response, as_json)
Ejemplo n.º 5
0
def test_now_ms():
    assert int(round(time.time() * 1000)) == Utils.now_ms()