From 96b55840ffc3c234b064a16000b1aad20ccba0e6 Mon Sep 17 00:00:00 2001 From: Daniel Moreno Date: Tue, 31 Aug 2021 16:04:06 +0200 Subject: [PATCH] refactor(tests): use pytest-recording --- dev_requirements.in | 1 + dev_requirements.txt | 51 +++++++++++++++++++++++++----------- giges/settings.py | 5 ++-- requirements.txt | 13 ++++----- test/integration/conftest.py | 13 +++++++++ 5 files changed, 58 insertions(+), 25 deletions(-) diff --git a/dev_requirements.in b/dev_requirements.in index 9a761f7..69098cd 100644 --- a/dev_requirements.in +++ b/dev_requirements.in @@ -6,5 +6,6 @@ pre-commit pytest pytest-cov pytest-factoryboy +pytest-recording mypy semgrep diff --git a/dev_requirements.txt b/dev_requirements.txt index 8bdb116..f27c7b3 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -4,20 +4,19 @@ # # pip-compile --output-file=./dev_requirements.txt dev_requirements.in # -appdirs==1.4.4 - # via black attrs==21.2.0 # via # jsonschema # pytest + # pytest-recording # semgrep backports.entry-points-selectable==1.1.0 # via virtualenv -black==21.7b0 +black==21.8b0 # via -r dev_requirements.in -boto3==1.18.30 +boto3==1.18.32 # via -r dev_requirements.in -botocore==1.21.30 +botocore==1.21.32 # via # boto3 # s3transfer @@ -48,7 +47,9 @@ flake8==3.9.2 identify==2.2.13 # via pre-commit idna==3.2 - # via requests + # via + # requests + # yarl inflection==0.5.1 # via pytest-factoryboy iniconfig==1.1.1 @@ -63,6 +64,8 @@ lxml==4.6.3 # via -r dev_requirements.in mccabe==0.6.1 # via flake8 +multidict==5.1.0 + # via yarl mypy==0.910 # via -r dev_requirements.in mypy-extensions==0.4.3 @@ -79,11 +82,13 @@ pathspec==0.9.0 # via black peewee==3.14.4 # via semgrep -platformdirs==2.2.0 - # via virtualenv -pluggy==0.13.1 +platformdirs==2.3.0 + # via + # black + # virtualenv +pluggy==1.0.0 # via pytest -pre-commit==2.14.0 +pre-commit==2.14.1 # via -r dev_requirements.in py==1.10.0 # via pytest @@ -95,26 +100,31 @@ pyparsing==2.4.7 # via packaging pyrsistent==0.18.0 # via jsonschema -pytest==6.2.4 +pytest==6.2.5 # via # -r dev_requirements.in # pytest-cov # pytest-factoryboy + # pytest-recording pytest-cov==2.12.1 # via -r dev_requirements.in pytest-factoryboy==2.1.0 # via -r dev_requirements.in +pytest-recording==0.12.0 + # via -r dev_requirements.in python-dateutil==2.8.2 # via # botocore # faker pyyaml==5.4.1 - # via pre-commit -regex==2021.8.27 + # via + # pre-commit + # vcrpy +regex==2021.8.28 # via black requests==2.26.0 # via semgrep -ruamel.yaml==0.17.14 +ruamel.yaml==0.17.16 # via semgrep ruamel.yaml.clib==0.2.6 # via ruamel.yaml @@ -126,6 +136,7 @@ six==1.16.0 # via # jsonschema # python-dateutil + # vcrpy # virtualenv text-unidecode==1.3 # via faker @@ -139,16 +150,24 @@ tomli==1.2.1 # via black tqdm==4.62.2 # via semgrep -typing-extensions==3.10.0.0 - # via mypy +typing-extensions==3.10.0.2 + # via + # black + # mypy urllib3==1.26.6 # via # botocore # requests +vcrpy==4.1.1 + # via pytest-recording virtualenv==20.7.2 # via pre-commit wcmatch==8.2 # via semgrep +wrapt==1.12.1 + # via vcrpy +yarl==1.6.3 + # via vcrpy # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/giges/settings.py b/giges/settings.py index 2209cbe..310352e 100644 --- a/giges/settings.py +++ b/giges/settings.py @@ -16,14 +16,13 @@ class BaseSettings: # Integrations SENTRY_URI = "" - ASANA_WORKSPACE = "" ASANA_TOKEN = os.environ.get("ASANA_TOKEN", "") + ASANA_WORKSPACE = "1199978051314275" class ProductionSettings(BaseSettings): ENVIRONMENT = "production" - ASANA_WORKSPACE = "1199978051314275" SERVER_BASE_URI = "https://integrations.tesselo.com" SENTRY_URI = "https://ec9a91e1ce0e40f59388c665c092dc2a@o640190.ingest.sentry.io/5911249" # noqa: E501 @@ -31,7 +30,7 @@ class ProductionSettings(BaseSettings): class StagingSettings(BaseSettings): ENVIRONMENT = "staging" - ASANA_WORKSPACE = "1200469161331386" + ASANA_WORKSPACE = "1199978051314275" SERVER_BASE_URI = "https://integrations-staging.tesselo.com" diff --git a/requirements.txt b/requirements.txt index c47c37e..d2630c7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ # # pip-compile --output-file=./requirements.txt requirements.in # -alembic==1.6.5 +alembic==1.7.1 # via flask-migrate argcomplete==1.12.3 # via zappa @@ -14,11 +14,11 @@ attrs==21.2.0 # via jsonschema blinker==1.4 # via sentry-sdk -boto3==1.18.30 +boto3==1.18.32 # via # kappa # zappa -botocore==1.21.30 +botocore==1.21.32 # via # boto3 # s3transfer @@ -66,6 +66,8 @@ hjson==3.0.2 # via zappa idna==3.2 # via requests +importlib-resources==5.2.2 + # via alembic inflection==0.5.1 # via connexion isodate==0.6.0 @@ -112,11 +114,8 @@ pyrsistent==0.18.0 # via jsonschema python-dateutil==2.8.2 # via - # alembic # botocore # zappa -python-editor==1.0.4 - # via alembic python-slugify==5.0.2 # via zappa pyyaml==5.4.1 @@ -186,6 +185,8 @@ wsgi-request-logger==0.4.6 # via zappa zappa==0.53.0 # via -r requirements.in +zipp==3.5.0 + # via importlib-resources # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/test/integration/conftest.py b/test/integration/conftest.py index fb9a7d2..7fe7e84 100644 --- a/test/integration/conftest.py +++ b/test/integration/conftest.py @@ -24,6 +24,11 @@ def app(connexion_app): yield app +@pytest.fixture +def cli_runner(app): + yield app.test_cli_runner() + + @pytest.fixture def client(app): with app.test_client() as client: @@ -55,3 +60,11 @@ def transactional_db(_db): for table in reversed(_db.metadata.sorted_tables): _db.session.execute(table.delete()) _db.session.commit() + + +@pytest.fixture(scope="module") +def vcr_config(): + return { + "decode_compressed_response": True, + "filter_headers": ["authorization"], + }