mockstack 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mockstack-0.3.0/mockstack.egg-info → mockstack-0.4.0}/PKG-INFO +10 -7
- {mockstack-0.3.0 → mockstack-0.4.0}/README.md +9 -6
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/config.py +51 -14
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/constants.py +4 -1
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/display.py +2 -1
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/lifespan.py +6 -1
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/main.py +16 -18
- {mockstack-0.3.0 → mockstack-0.4.0/mockstack.egg-info}/PKG-INFO +10 -7
- mockstack-0.4.0/mockstack.egg-info/entry_points.txt +2 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/pyproject.toml +1 -1
- mockstack-0.3.0/mockstack.egg-info/entry_points.txt +0 -2
- {mockstack-0.3.0 → mockstack-0.4.0}/.env.example +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/.github/workflows/ci.yml +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/.github/workflows/publish-docs.yml +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/.github/workflows/publish-to-pypi.yml +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/.gitignore +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/.pre-commit-config.yaml +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/CODE_OF_CONDUCT.md +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/LICENSE +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/SECURITY.md +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/docs/assets/favicon.ico +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/docs/assets/logo.png +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/docs/assets/mockstack.png +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mkdocs.yml +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/__init__.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/identifiers.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/intent.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/middleware.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/routers/__init__.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/routers/catchall.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/routers/homepage.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/strategies/__init__.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/strategies/base.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/strategies/create_mixin.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/strategies/factory.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/strategies/filefixtures.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/strategies/proxyrules.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/telemetry.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/templating.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/__init__.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/conftest.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/fixtures/proxyrules.yml +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/fixtures/templates/__init__.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/fixtures/templates/example-template.j2 +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/routers/__init__.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/routers/test_catchall.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/routers/test_homepage.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/strategies/test_filefixtures.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/strategies/test_proxyrules.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/test_display.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/test_identifiers.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/test_middleware.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack/tests/test_templating.py +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack.egg-info/SOURCES.txt +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack.egg-info/dependency_links.txt +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack.egg-info/requires.txt +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/mockstack.egg-info/top_level.txt +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/setup.cfg +0 -0
- {mockstack-0.3.0 → mockstack-0.4.0}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mockstack
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: An API mocking workhorse
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/adamhadani/mockstack
|
|
@@ -47,7 +47,7 @@ Highlights include:
|
|
|
47
47
|
|
|
48
48
|
Install using [uv](https://docs.astral.sh/uv/). This package conforms the concept of a [tool](https://docs.astral.sh/uv/concepts/tools/) and hence can simply install / run with `uvx`:
|
|
49
49
|
|
|
50
|
-
uvx mockstack
|
|
50
|
+
uvx mockstack --help
|
|
51
51
|
|
|
52
52
|
or install into a persistent environment and add it to the PATH with:
|
|
53
53
|
|
|
@@ -56,15 +56,20 @@ or install into a persistent environment and add it to the PATH with:
|
|
|
56
56
|
|
|
57
57
|
## Usage
|
|
58
58
|
|
|
59
|
-
Available configuration options are [here](https://github.com/adamhadani/mockstack/blob/main/mockstack/config.py).
|
|
59
|
+
Available configuration options are [here](https://github.com/adamhadani/mockstack/blob/main/mockstack/config.py).
|
|
60
|
+
|
|
61
|
+
Setting individual options can be done either through an `.env` file, individual environment variables, or command-line arguments. For example:
|
|
60
62
|
|
|
61
63
|
```shell
|
|
64
|
+
export MOCKSTACK__STRATEGY=filefixtures
|
|
62
65
|
export MOCKSTACK__TEMPLATES_DIR=~/mockstack-templates/
|
|
63
66
|
export MOCKSTACK__OPENTELEMETRY__ENABLED=true
|
|
64
67
|
export MOCKSTACK__OPENTELEMETRY__CAPTURE_RESPONSE_BODY=true
|
|
65
|
-
|
|
68
|
+
uvx mockstack
|
|
66
69
|
```
|
|
67
70
|
|
|
71
|
+
See also the included [.env.example](https://github.com/adamhadani/mockstack/blob/main/.env.example) for more examples. You can copy that file to `.env` and fill in configuration as needed based on the given examples.
|
|
72
|
+
|
|
68
73
|
Out of the box, you get the following behavior when using the default `filefixtures` strategy:
|
|
69
74
|
|
|
70
75
|
- The HTTP request `GET /someservice/api/v1/user/c27f5b2b-6e81-420d-a4e4-6426e1c32db8` will try to find `<templates_dir>/someservice-api-v1-user.c27f5b2b-6e81-420d-a4e4-6426e1c32db8.j2`,
|
|
@@ -97,8 +102,6 @@ If you are contributing to development, you will want to clone this project, and
|
|
|
97
102
|
uv sync
|
|
98
103
|
uv pip install -e .
|
|
99
104
|
|
|
100
|
-
Copy the included [.env.example](https://github.com/adamhadani/mockstack/blob/main/.env.example) file to `.env` and fill in configuration as needed based on the given examples.
|
|
101
|
-
|
|
102
105
|
Run in development mode (for live-reload of changes when developing):
|
|
103
106
|
|
|
104
|
-
uv run
|
|
107
|
+
uv run -- mockstack --debug
|
|
@@ -23,7 +23,7 @@ Highlights include:
|
|
|
23
23
|
|
|
24
24
|
Install using [uv](https://docs.astral.sh/uv/). This package conforms the concept of a [tool](https://docs.astral.sh/uv/concepts/tools/) and hence can simply install / run with `uvx`:
|
|
25
25
|
|
|
26
|
-
uvx mockstack
|
|
26
|
+
uvx mockstack --help
|
|
27
27
|
|
|
28
28
|
or install into a persistent environment and add it to the PATH with:
|
|
29
29
|
|
|
@@ -32,15 +32,20 @@ or install into a persistent environment and add it to the PATH with:
|
|
|
32
32
|
|
|
33
33
|
## Usage
|
|
34
34
|
|
|
35
|
-
Available configuration options are [here](https://github.com/adamhadani/mockstack/blob/main/mockstack/config.py).
|
|
35
|
+
Available configuration options are [here](https://github.com/adamhadani/mockstack/blob/main/mockstack/config.py).
|
|
36
|
+
|
|
37
|
+
Setting individual options can be done either through an `.env` file, individual environment variables, or command-line arguments. For example:
|
|
36
38
|
|
|
37
39
|
```shell
|
|
40
|
+
export MOCKSTACK__STRATEGY=filefixtures
|
|
38
41
|
export MOCKSTACK__TEMPLATES_DIR=~/mockstack-templates/
|
|
39
42
|
export MOCKSTACK__OPENTELEMETRY__ENABLED=true
|
|
40
43
|
export MOCKSTACK__OPENTELEMETRY__CAPTURE_RESPONSE_BODY=true
|
|
41
|
-
|
|
44
|
+
uvx mockstack
|
|
42
45
|
```
|
|
43
46
|
|
|
47
|
+
See also the included [.env.example](https://github.com/adamhadani/mockstack/blob/main/.env.example) for more examples. You can copy that file to `.env` and fill in configuration as needed based on the given examples.
|
|
48
|
+
|
|
44
49
|
Out of the box, you get the following behavior when using the default `filefixtures` strategy:
|
|
45
50
|
|
|
46
51
|
- The HTTP request `GET /someservice/api/v1/user/c27f5b2b-6e81-420d-a4e4-6426e1c32db8` will try to find `<templates_dir>/someservice-api-v1-user.c27f5b2b-6e81-420d-a4e4-6426e1c32db8.j2`,
|
|
@@ -73,8 +78,6 @@ If you are contributing to development, you will want to clone this project, and
|
|
|
73
78
|
uv sync
|
|
74
79
|
uv pip install -e .
|
|
75
80
|
|
|
76
|
-
Copy the included [.env.example](https://github.com/adamhadani/mockstack/blob/main/.env.example) file to `.env` and fill in configuration as needed based on the given examples.
|
|
77
|
-
|
|
78
81
|
Run in development mode (for live-reload of changes when developing):
|
|
79
82
|
|
|
80
|
-
uv run
|
|
83
|
+
uv run -- mockstack --debug
|
|
@@ -2,9 +2,19 @@ from functools import lru_cache
|
|
|
2
2
|
from typing import Any, Literal, Self
|
|
3
3
|
|
|
4
4
|
from pydantic import DirectoryPath, FilePath, model_validator
|
|
5
|
-
from pydantic_settings import
|
|
5
|
+
from pydantic_settings import (
|
|
6
|
+
BaseSettings,
|
|
7
|
+
CliImplicitFlag,
|
|
8
|
+
CliSuppress,
|
|
9
|
+
SettingsConfigDict,
|
|
10
|
+
)
|
|
6
11
|
|
|
7
|
-
from mockstack.constants import
|
|
12
|
+
from mockstack.constants import (
|
|
13
|
+
ENV_FILE,
|
|
14
|
+
ENV_NESTED_DELIMITER,
|
|
15
|
+
ENV_PREFIX,
|
|
16
|
+
ProxyRulesRedirectVia,
|
|
17
|
+
)
|
|
8
18
|
|
|
9
19
|
|
|
10
20
|
class OpenTelemetrySettings(BaseSettings):
|
|
@@ -28,11 +38,20 @@ class Settings(BaseSettings):
|
|
|
28
38
|
"""
|
|
29
39
|
|
|
30
40
|
model_config = SettingsConfigDict(
|
|
31
|
-
env_prefix=
|
|
32
|
-
env_file=
|
|
33
|
-
env_nested_delimiter=
|
|
41
|
+
env_prefix=ENV_PREFIX,
|
|
42
|
+
env_file=ENV_FILE,
|
|
43
|
+
env_nested_delimiter=ENV_NESTED_DELIMITER,
|
|
34
44
|
)
|
|
35
45
|
|
|
46
|
+
# whether to run in debug mode
|
|
47
|
+
debug: CliImplicitFlag[bool] = False
|
|
48
|
+
|
|
49
|
+
# host to run the server on
|
|
50
|
+
host: str = "0.0.0.0"
|
|
51
|
+
|
|
52
|
+
# port to run the server on
|
|
53
|
+
port: int = 8000
|
|
54
|
+
|
|
36
55
|
# OpenTelemetry configuration
|
|
37
56
|
opentelemetry: OpenTelemetrySettings = OpenTelemetrySettings()
|
|
38
57
|
|
|
@@ -51,11 +70,11 @@ class Settings(BaseSettings):
|
|
|
51
70
|
|
|
52
71
|
# controls behavior of proxying. Whether to simulate creation of resources
|
|
53
72
|
# when a POST request is made to a resource that doesn't match any rules..
|
|
54
|
-
proxyrules_simulate_create_on_missing: bool = False
|
|
73
|
+
proxyrules_simulate_create_on_missing: CliImplicitFlag[bool] = False
|
|
55
74
|
|
|
56
75
|
# metadata fields to inject into created resources.
|
|
57
76
|
# A few template fields are available. See documentation for more details.
|
|
58
|
-
created_resource_metadata: dict[str, Any] = {
|
|
77
|
+
created_resource_metadata: CliSuppress[dict[str, Any]] = {
|
|
59
78
|
"id": "{{ uuid4() }}",
|
|
60
79
|
"createdAt": "{{ utcnow().isoformat() }}",
|
|
61
80
|
"updatedAt": "{{ utcnow().isoformat() }}",
|
|
@@ -65,7 +84,7 @@ class Settings(BaseSettings):
|
|
|
65
84
|
|
|
66
85
|
# fields to inject into missing resources response json.
|
|
67
86
|
# some services may require such additional fields to be present in the response.
|
|
68
|
-
missing_resource_fields: dict[str, Any] = dict(
|
|
87
|
+
missing_resource_fields: CliSuppress[dict[str, Any]] = dict(
|
|
69
88
|
code=404,
|
|
70
89
|
message="mockstack: resource not found",
|
|
71
90
|
retryable=False,
|
|
@@ -73,7 +92,7 @@ class Settings(BaseSettings):
|
|
|
73
92
|
|
|
74
93
|
# logging configuration. schema is based on the logging configuration schema:
|
|
75
94
|
# https://docs.python.org/3/library/logging.config.html#logging-config-dictschema
|
|
76
|
-
logging: dict[str, Any] = {
|
|
95
|
+
logging: CliSuppress[dict[str, Any]] = {
|
|
77
96
|
"version": 1,
|
|
78
97
|
"disable_existing_loggers": False,
|
|
79
98
|
"formatters": {
|
|
@@ -85,7 +104,7 @@ class Settings(BaseSettings):
|
|
|
85
104
|
"handlers": {
|
|
86
105
|
"console": {
|
|
87
106
|
"class": "logging.StreamHandler",
|
|
88
|
-
"level": "
|
|
107
|
+
"level": "INFO",
|
|
89
108
|
"formatter": "standard",
|
|
90
109
|
"stream": "ext://sys.stdout",
|
|
91
110
|
},
|
|
@@ -93,23 +112,23 @@ class Settings(BaseSettings):
|
|
|
93
112
|
"loggers": {
|
|
94
113
|
"uvicorn": {
|
|
95
114
|
"handlers": ["console"],
|
|
96
|
-
"level": "
|
|
115
|
+
"level": "DEBUG",
|
|
97
116
|
"propagate": False,
|
|
98
117
|
},
|
|
99
118
|
"FileFixturesStrategy": {
|
|
100
119
|
"handlers": ["console"],
|
|
101
|
-
"level": "
|
|
120
|
+
"level": "DEBUG",
|
|
102
121
|
"propagate": False,
|
|
103
122
|
},
|
|
104
123
|
"ProxyRulesStrategy": {
|
|
105
124
|
"handlers": ["console"],
|
|
106
|
-
"level": "
|
|
125
|
+
"level": "DEBUG",
|
|
107
126
|
"propagate": False,
|
|
108
127
|
},
|
|
109
128
|
},
|
|
110
129
|
"root": {
|
|
111
130
|
"handlers": ["console"],
|
|
112
|
-
"level": "
|
|
131
|
+
"level": "DEBUG",
|
|
113
132
|
"propagate": False,
|
|
114
133
|
},
|
|
115
134
|
}
|
|
@@ -135,6 +154,24 @@ class Settings(BaseSettings):
|
|
|
135
154
|
return self
|
|
136
155
|
|
|
137
156
|
|
|
157
|
+
# Nb. We separate the Cli-specific parameters since currently breaks pytest
|
|
158
|
+
# when running via pre-commit hooks. Can remove once fixed by pytest / pre-commit.
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class CliSettings(Settings):
|
|
162
|
+
"""Settings for mockstack CLI."""
|
|
163
|
+
|
|
164
|
+
model_config = SettingsConfigDict(
|
|
165
|
+
env_prefix=ENV_PREFIX,
|
|
166
|
+
env_file=ENV_FILE,
|
|
167
|
+
env_nested_delimiter=ENV_NESTED_DELIMITER,
|
|
168
|
+
cli_parse_args=True,
|
|
169
|
+
cli_kebab_case=True,
|
|
170
|
+
cli_hide_none_type=True,
|
|
171
|
+
cli_avoid_json=True,
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
|
|
138
175
|
@lru_cache
|
|
139
176
|
def settings_provider() -> Settings:
|
|
140
177
|
"""Provide the settings for the application."""
|
|
@@ -27,7 +27,8 @@ def announce(app: FastAPI, settings: Settings):
|
|
|
27
27
|
logger = logging.getLogger("uvicorn")
|
|
28
28
|
logger.info(
|
|
29
29
|
f"{HIGHLIGHT}mockstack{ENDC} ready to roll. "
|
|
30
|
-
f"
|
|
30
|
+
f"debug: {HIGHLIGHT}{settings.debug}{ENDC}. "
|
|
31
|
+
f"strategy: {HIGHLIGHT}{settings.strategy}{ENDC}. "
|
|
31
32
|
)
|
|
32
33
|
logger.info(str(app.state.strategy))
|
|
33
34
|
logger.info(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""FastAPI application lifecycle management."""
|
|
2
2
|
|
|
3
3
|
from contextlib import asynccontextmanager
|
|
4
|
-
from logging import config
|
|
4
|
+
from logging import DEBUG, config
|
|
5
5
|
from typing import Callable
|
|
6
6
|
|
|
7
7
|
from fastapi import FastAPI
|
|
@@ -21,7 +21,12 @@ def lifespan_provider(
|
|
|
21
21
|
|
|
22
22
|
This is the context manager that FastAPI will use to manage the lifecycle of the application.
|
|
23
23
|
"""
|
|
24
|
+
if settings.debug:
|
|
25
|
+
# Enable verbose debug logging if debug mode is set.
|
|
26
|
+
settings.logging["handlers"]["console"]["level"] = DEBUG
|
|
27
|
+
|
|
24
28
|
config.dictConfig(settings.logging)
|
|
29
|
+
|
|
25
30
|
announce(app, settings)
|
|
26
31
|
|
|
27
32
|
yield
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"""Application entrypoints."""
|
|
2
2
|
|
|
3
3
|
from fastapi import FastAPI
|
|
4
|
-
from
|
|
4
|
+
from pydantic_settings import CliApp, CliSettingsSource
|
|
5
5
|
|
|
6
|
-
from mockstack.config import settings_provider
|
|
6
|
+
from mockstack.config import CliSettings, Settings, settings_provider
|
|
7
7
|
from mockstack.lifespan import lifespan_provider
|
|
8
8
|
from mockstack.middleware import middleware_provider
|
|
9
9
|
from mockstack.routers.catchall import catchall_router_provider
|
|
@@ -11,12 +11,10 @@ from mockstack.routers.homepage import homepage_router_provider
|
|
|
11
11
|
from mockstack.strategies.factory import strategy_provider
|
|
12
12
|
from mockstack.telemetry import opentelemetry_provider
|
|
13
13
|
|
|
14
|
-
cli = Typer()
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
settings = settings_provider()
|
|
15
|
+
def create_app(settings: Settings | None = None) -> FastAPI:
|
|
16
|
+
"""Create the fastapi app and bootstrap all dependencies."""
|
|
17
|
+
settings = settings or settings_provider()
|
|
20
18
|
|
|
21
19
|
app = FastAPI(lifespan=lifespan_provider(settings))
|
|
22
20
|
|
|
@@ -30,23 +28,23 @@ def create_app() -> FastAPI:
|
|
|
30
28
|
return app
|
|
31
29
|
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
def run():
|
|
32
|
+
"""run the mockstack server."""
|
|
33
|
+
import argparse
|
|
36
34
|
import uvicorn
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
parser = argparse.ArgumentParser()
|
|
37
|
+
cli_settings = CliSettingsSource(CliSettings, root_parser=parser)
|
|
38
|
+
settings = CliApp.run(CliSettings, cli_settings_source=cli_settings)
|
|
39
|
+
|
|
40
|
+
app = create_app(settings=settings)
|
|
41
|
+
|
|
42
|
+
uvicorn.run(app, host=settings.host, port=settings.port)
|
|
40
43
|
|
|
41
44
|
|
|
42
|
-
@cli.command()
|
|
43
45
|
def version():
|
|
44
|
-
"""mockstack version
|
|
46
|
+
"""display mockstack version."""
|
|
45
47
|
from importlib.metadata import version
|
|
46
48
|
|
|
47
49
|
pkg_version = version("mockstack")
|
|
48
50
|
print(f"mockstack {pkg_version}")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if __name__ == "__main__":
|
|
52
|
-
cli()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mockstack
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: An API mocking workhorse
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/adamhadani/mockstack
|
|
@@ -47,7 +47,7 @@ Highlights include:
|
|
|
47
47
|
|
|
48
48
|
Install using [uv](https://docs.astral.sh/uv/). This package conforms the concept of a [tool](https://docs.astral.sh/uv/concepts/tools/) and hence can simply install / run with `uvx`:
|
|
49
49
|
|
|
50
|
-
uvx mockstack
|
|
50
|
+
uvx mockstack --help
|
|
51
51
|
|
|
52
52
|
or install into a persistent environment and add it to the PATH with:
|
|
53
53
|
|
|
@@ -56,15 +56,20 @@ or install into a persistent environment and add it to the PATH with:
|
|
|
56
56
|
|
|
57
57
|
## Usage
|
|
58
58
|
|
|
59
|
-
Available configuration options are [here](https://github.com/adamhadani/mockstack/blob/main/mockstack/config.py).
|
|
59
|
+
Available configuration options are [here](https://github.com/adamhadani/mockstack/blob/main/mockstack/config.py).
|
|
60
|
+
|
|
61
|
+
Setting individual options can be done either through an `.env` file, individual environment variables, or command-line arguments. For example:
|
|
60
62
|
|
|
61
63
|
```shell
|
|
64
|
+
export MOCKSTACK__STRATEGY=filefixtures
|
|
62
65
|
export MOCKSTACK__TEMPLATES_DIR=~/mockstack-templates/
|
|
63
66
|
export MOCKSTACK__OPENTELEMETRY__ENABLED=true
|
|
64
67
|
export MOCKSTACK__OPENTELEMETRY__CAPTURE_RESPONSE_BODY=true
|
|
65
|
-
|
|
68
|
+
uvx mockstack
|
|
66
69
|
```
|
|
67
70
|
|
|
71
|
+
See also the included [.env.example](https://github.com/adamhadani/mockstack/blob/main/.env.example) for more examples. You can copy that file to `.env` and fill in configuration as needed based on the given examples.
|
|
72
|
+
|
|
68
73
|
Out of the box, you get the following behavior when using the default `filefixtures` strategy:
|
|
69
74
|
|
|
70
75
|
- The HTTP request `GET /someservice/api/v1/user/c27f5b2b-6e81-420d-a4e4-6426e1c32db8` will try to find `<templates_dir>/someservice-api-v1-user.c27f5b2b-6e81-420d-a4e4-6426e1c32db8.j2`,
|
|
@@ -97,8 +102,6 @@ If you are contributing to development, you will want to clone this project, and
|
|
|
97
102
|
uv sync
|
|
98
103
|
uv pip install -e .
|
|
99
104
|
|
|
100
|
-
Copy the included [.env.example](https://github.com/adamhadani/mockstack/blob/main/.env.example) file to `.env` and fill in configuration as needed based on the given examples.
|
|
101
|
-
|
|
102
105
|
Run in development mode (for live-reload of changes when developing):
|
|
103
106
|
|
|
104
|
-
uv run
|
|
107
|
+
uv run -- mockstack --debug
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|