mockstack 0.5.1__tar.gz → 0.5.2__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.
Files changed (65) hide show
  1. {mockstack-0.5.1 → mockstack-0.5.2}/PKG-INFO +1 -1
  2. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/display.py +2 -2
  3. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/strategies/create_mixin.py +14 -0
  4. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/strategies/filefixtures.py +1 -1
  5. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/strategies/proxyrules.py +5 -4
  6. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/test_display.py +1 -1
  7. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack.egg-info/PKG-INFO +1 -1
  8. {mockstack-0.5.1 → mockstack-0.5.2}/.env.example +0 -0
  9. {mockstack-0.5.1 → mockstack-0.5.2}/.github/workflows/ci.yml +0 -0
  10. {mockstack-0.5.1 → mockstack-0.5.2}/.github/workflows/publish-docs.yml +0 -0
  11. {mockstack-0.5.1 → mockstack-0.5.2}/.github/workflows/publish-to-pypi.yml +0 -0
  12. {mockstack-0.5.1 → mockstack-0.5.2}/.gitignore +0 -0
  13. {mockstack-0.5.1 → mockstack-0.5.2}/.pre-commit-config.yaml +0 -0
  14. {mockstack-0.5.1 → mockstack-0.5.2}/CODE_OF_CONDUCT.md +0 -0
  15. {mockstack-0.5.1 → mockstack-0.5.2}/LICENSE +0 -0
  16. {mockstack-0.5.1 → mockstack-0.5.2}/README.md +0 -0
  17. {mockstack-0.5.1 → mockstack-0.5.2}/SECURITY.md +0 -0
  18. {mockstack-0.5.1 → mockstack-0.5.2}/docs/assets/favicon.ico +0 -0
  19. {mockstack-0.5.1 → mockstack-0.5.2}/docs/assets/logo.png +0 -0
  20. {mockstack-0.5.1 → mockstack-0.5.2}/docs/assets/mockstack.png +0 -0
  21. {mockstack-0.5.1 → mockstack-0.5.2}/examples/filefixtures-with-templates/.env.example +0 -0
  22. {mockstack-0.5.1 → mockstack-0.5.2}/examples/filefixtures-with-templates/README.md +0 -0
  23. {mockstack-0.5.1 → mockstack-0.5.2}/examples/filefixtures-with-templates/templates/servicename-api-v1-items.j2 +0 -0
  24. {mockstack-0.5.1 → mockstack-0.5.2}/examples/filefixtures-with-templates/templates/servicename2-api-v2-user.533ec889-7c68-45c8-b21e-4a7e455d1234.j2 +0 -0
  25. {mockstack-0.5.1 → mockstack-0.5.2}/examples/proxyrules-with-rules-file/.env.example +0 -0
  26. {mockstack-0.5.1 → mockstack-0.5.2}/examples/proxyrules-with-rules-file/README.md +0 -0
  27. {mockstack-0.5.1 → mockstack-0.5.2}/examples/proxyrules-with-rules-file/rules.yml +0 -0
  28. {mockstack-0.5.1 → mockstack-0.5.2}/mkdocs.yml +0 -0
  29. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/__init__.py +0 -0
  30. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/config.py +0 -0
  31. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/constants.py +0 -0
  32. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/identifiers.py +0 -0
  33. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/intent.py +0 -0
  34. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/lifespan.py +0 -0
  35. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/main.py +0 -0
  36. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/middleware.py +0 -0
  37. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/routers/__init__.py +0 -0
  38. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/routers/catchall.py +0 -0
  39. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/routers/homepage.py +0 -0
  40. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/strategies/__init__.py +0 -0
  41. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/strategies/base.py +0 -0
  42. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/strategies/factory.py +0 -0
  43. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/telemetry.py +0 -0
  44. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/templating.py +0 -0
  45. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/__init__.py +0 -0
  46. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/conftest.py +0 -0
  47. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/fixtures/proxyrules.yml +0 -0
  48. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/fixtures/templates/__init__.py +0 -0
  49. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/fixtures/templates/example-template.j2 +0 -0
  50. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/routers/__init__.py +0 -0
  51. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/routers/test_catchall.py +0 -0
  52. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/routers/test_homepage.py +0 -0
  53. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/strategies/test_filefixtures.py +0 -0
  54. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/strategies/test_proxyrules.py +0 -0
  55. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/test_identifiers.py +0 -0
  56. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/test_middleware.py +0 -0
  57. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack/tests/test_templating.py +0 -0
  58. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack.egg-info/SOURCES.txt +0 -0
  59. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack.egg-info/dependency_links.txt +0 -0
  60. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack.egg-info/entry_points.txt +0 -0
  61. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack.egg-info/requires.txt +0 -0
  62. {mockstack-0.5.1 → mockstack-0.5.2}/mockstack.egg-info/top_level.txt +0 -0
  63. {mockstack-0.5.1 → mockstack-0.5.2}/pyproject.toml +0 -0
  64. {mockstack-0.5.1 → mockstack-0.5.2}/setup.cfg +0 -0
  65. {mockstack-0.5.1 → mockstack-0.5.2}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mockstack
3
- Version: 0.5.1
3
+ Version: 0.5.2
4
4
  Summary: An API mocking workhorse
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://github.com/adamhadani/mockstack
@@ -20,8 +20,8 @@ def announce(app: FastAPI, settings: Settings):
20
20
  )
21
21
  logger.info(str(app.state.strategy), extra=extra)
22
22
  logger.info(
23
- f"OpenTelemetry enabled: [medium_purple]{settings.opentelemetry.enabled}[/medium_purple], "
24
- f"endpoint: [medium_purple]{settings.opentelemetry.endpoint}[/medium_purple], "
23
+ f"[medium_purple]OpenTelemetry[/medium_purple] enabled: [medium_purple]{settings.opentelemetry.enabled}[/medium_purple],\n "
24
+ f"endpoint: [medium_purple]{settings.opentelemetry.endpoint}[/medium_purple],\n "
25
25
  f"capture_response_body: [medium_purple]{settings.opentelemetry.capture_response_body}[/medium_purple]",
26
26
  extra=extra,
27
27
  )
@@ -2,6 +2,7 @@
2
2
 
3
3
  from datetime import datetime, timezone
4
4
  from uuid import uuid4
5
+ import json
5
6
 
6
7
  from fastapi import Request, Response, status
7
8
  from fastapi.responses import JSONResponse
@@ -16,6 +17,9 @@ class CreateMixin:
16
17
  async def _create(
17
18
  self, request: Request, *, env: Environment, created_resource_metadata: dict
18
19
  ) -> Response:
20
+ """Simulate creation of a resource."""
21
+ self._create_mixin_update_opentelemetry(request, created_resource_metadata)
22
+
19
23
  if wants_json(request):
20
24
  # We return a 201 CREATED response with the resource as the body,
21
25
  # potentially injecting the resource ID into the response.
@@ -79,3 +83,13 @@ class CreateMixin:
79
83
  "uuid4": uuid4,
80
84
  "request": request,
81
85
  }
86
+
87
+ def _create_mixin_update_opentelemetry(
88
+ self, request: Request, created_resource_metadata: dict
89
+ ) -> None:
90
+ """Update the opentelemetry span with the create mixin details."""
91
+ span = request.state.span
92
+ span.set_attribute(
93
+ "mockstack.create_mixin.created_resource_metadata",
94
+ json.dumps(created_resource_metadata),
95
+ )
@@ -39,7 +39,7 @@ class FileFixturesStrategy(BaseStrategy, CreateMixin):
39
39
 
40
40
  def __str__(self) -> str:
41
41
  return (
42
- f"[medium_purple]filefixtures[/medium_purple] "
42
+ f"[medium_purple]filefixtures[/medium_purple]\n "
43
43
  f"templates_dir: [medium_purple]{self.templates_dir}[/medium_purple]. "
44
44
  )
45
45
 
@@ -77,10 +77,11 @@ class ProxyRulesStrategy(BaseStrategy, CreateMixin):
77
77
 
78
78
  def __str__(self) -> str:
79
79
  return (
80
- f"[medium_purple]proxyrules[/medium_purple] "
81
- f"rules_filename: [medium_purple]{self.rules_filename}[/medium_purple]. "
82
- f"redirect_via: [medium_purple]{self.redirect_via}[/medium_purple]. "
83
- f"simulate_create_on_missing: [medium_purple]{self.simulate_create_on_missing}[/medium_purple]"
80
+ f"[medium_purple]proxyrules[/medium_purple]\n "
81
+ f"rules_filename: {self.rules_filename}.\n "
82
+ f"redirect_via: [medium_purple]{self.redirect_via}[/medium_purple].\n "
83
+ f"simulate_create_on_missing: {self.simulate_create_on_missing}.\n "
84
+ f"reverse_proxy_timeout: {self.reverse_proxy_timeout}"
84
85
  )
85
86
 
86
87
  @cached_property
@@ -17,4 +17,4 @@ def test_announce(app, settings):
17
17
 
18
18
  # Check that the log message contains the expected information
19
19
  first_log_message = mock_logger.info.call_args[0][0]
20
- assert "OpenTelemetry enabled:" in first_log_message
20
+ assert "OpenTelemetry" in first_log_message
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mockstack
3
- Version: 0.5.1
3
+ Version: 0.5.2
4
4
  Summary: An API mocking workhorse
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://github.com/adamhadani/mockstack
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