This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: tests/test_dry_demo_01.py | |
import re | |
from hypothesis import assume, example, given, strategies | |
from app.dry_demo_01 import drn_pattern, is_valid_project_drn | |
valid_drn = strategies.from_regex(drn_pattern) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: app/dry_demo_01.py | |
import re | |
# The urn pattern describe a workspace, and a resource id | |
# Examples: | |
# drn:23f742:bc4b57dd0bec433198a58cd36b6c7ee8 | |
# (drn for Demo Resource Name, or random identifier for demo purposes) | |
drn_pattern = r"^drn:[a-z0-9]{6}:[a-f0-9]{32}$" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
# find-bom searches for nonbinary files starting with a BOM marker | |
# Path of BOM-encoded files is print to stdout | |
# Exit status is 0 if no BOM files has been found | |
# Exit status is 1 if at least one BOM file has been found | |
readonly TARGET_ROOT=${1:-$PWD} | |
echo "Searching for BOM in $TARGET_ROOT" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask.testing import FlaskClient | |
class ApiTestClient(FlaskClient): | |
def open(self, *args, **kw): | |
resp: Response = super().open(*args, **kw) | |
# Send a copy of the request to the sink so that it’s visible for the Akita Agent | |
resp.freeze() | |
_publish_to_exposer(kw, deepcopy(resp)) | |
return resp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@fixture(scope="session") | |
def exposer_thread(request): | |
start_exposer_thread() | |
def close(): | |
stop_exposer_thread() | |
request.addfinalizer(close) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.fixture | |
- def test_client(): | |
+ def test_client(exposer_thread): | |
configure_app(flask_app, config_name=Environments.TESTS) | |
# I use this a lot for custom Test client classes to inject custom things | |
my_project.app.test_client_class = CustomApiTestClient | |
client = my_project.app.test_client | |
yield client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.fixture | |
def client(): | |
my_project.app.config['TESTING'] = True | |
with my_project.app.test_client() as client: | |
with my_project.app.app_context(): | |
# Do some initialization stuff | |
yield client | |
# Or |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: tests/api_helpers.py | |
import logging | |
import threading | |
from copy import deepcopy | |
from threading import Thread | |
from typing import Optional | |
from uuid import uuid4 | |
import requests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
dumpInstances() { | |
local readonly region="$1" | |
local readonly date_ts="$(date +%Y%m%d-%H%M)" | |
aws ec2 describe-instances \ | |
--max-items 200 \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
dumpInstances() { | |
local readonly region="$1" | |
local readonly date_ts="$(date +%Y%m%d-%H%M)" | |
aws ec2 describe-instances \ | |
--max-items 200 \ |
NewerOlder