Skip to content
Snippets Groups Projects
Commit b188683a authored by Dariusz Kędzierski's avatar Dariusz Kędzierski
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #21553 canceled
LICENSE 0 → 100644
Copyright 2020 Mentat Software
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[metadata]
name = tavern-time-request
description = Tavern plugin to add sent timestamp to request headers
version = attr: tavern_time_request.__version__
# long_description = file: README.rst
author = Dariusz Kędzierski
author_email = dkedzierski@syncad.com
url = https://taverntesting.github.io/
license = MIT
license_file = LICENSE
keywords =
testing
pytest
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Framework :: Pytest
Programming Language :: Python :: 3.6
Topic :: Utilities
Topic :: Software Development :: Testing
License :: OSI Approved :: MIT License
[options]
packages = find:
include_package_data = True
install_requires =
tavern
future
[options.packages.find]
exclude =
tests
[options.entry_points]
tavern_http =
timeit = tavern_time_request.tavernhook:TavernTimeRequestPlugin
[bdist_wheel]
universal = 1
[aliases]
test=pytest
setup.py 0 → 100644
#!/usr/bin/env python
from setuptools import setup
SETUP_REQUIRES = [
"setuptools>=36",
"pytest-runner",
]
setup(
name="tavern_time_request",
setup_requires=SETUP_REQUIRES,
)
__version__ = "0.0.1"
import logging
import requests
from tavern.util import exceptions
from tavern._plugins.rest.request import RestRequest
from time import perf_counter as perf
logger = logging.getLogger(__name__)
class HivemindRequest(RestRequest):
def run(self):
try:
# add sent timestamp to each request in perf_counter format
start_time = perf()
headers = self._request_args.get('headers', {})
headers['Sent-At'] = str(start_time)
self._request_args['headers'] = headers
return self._prepared()
except requests.exceptions.RequestException as e:
logger.exception("Error running prepared request")
raise exceptions.RestRequestException from e
import logging
from tavern._plugins.rest.response import RestResponse
logger = logging.getLogger(__name__)
class HivemindResponse(RestResponse):
pass
\ No newline at end of file
import logging
from tavern._plugins.rest.tavernhook import TavernRestPlugin
from .request import HivemindRequest
from .response import HivemindResponse
logger = logging.getLogger(__name__)
class TavernTimeRequestPlugin(TavernRestPlugin):
request_type = HivemindRequest
request_block_name = "request"
verifier_type = HivemindResponse
response_block_name = "response"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment