Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elic-eon committed Sep 10, 2024
1 parent afad828 commit f4b8dd7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/dbt/cloud/test_http.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import json

import httpx
from testcontainers.general import DockerContainer

from metaphor.common.logger import debug_files
from metaphor.dbt.cloud.http import LogTransport


def test_http_client():
http_client = httpx.Client(
transport=LogTransport(httpx.HTTPTransport()),
)

with DockerContainer("hashicorp/http-echo").with_exposed_ports(5678).with_env(
"ECHO_TEXT", json.dumps({})
) as container:
port = container.get_exposed_port(5678)
host = container.get_container_host_ip()

url = f"http://{host}:{port}"
http_client.post(url, content=json.dumps({"foo": "bar"}))

# Should log two json file
assert len(debug_files) == 2

0 comments on commit f4b8dd7

Please sign in to comment.