Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions recipes/req/recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
context:
version: "0.1.0"
version: "0.2.0"
mojo_version: "==1.1.0"

package:
Expand All @@ -8,7 +8,7 @@ package:

source:
- git: https://github.com/mojoto/req.mojo.git
rev: c46152a5d77adf17b85ebb40fe90106a0522e0ee # v0.1.0
rev: 40d245911d3e681dfb7e837d4a097d0f2ce58af9 # 0.2.0 preparation source; no release tag
- git: https://github.com/ehsanmok/json.git
rev: 0bae1f3815d249efa6cb0a3483eb6658700635e5 # v0.4.1
target_directory: vendor/json
Expand Down Expand Up @@ -56,15 +56,20 @@ tests:
interpreter: bash
content: |
set -euo pipefail
mojo build --Werror test.mojo -o test-req
mojo build --Werror tests/package.mojo -o test-req
python test.py
files:
recipe:
- test.mojo
- test.py
source:
- tests/package.mojo
- tests/conftest.py
- tests/transports/http2_server.py
requirements:
run:
- python >=3.12
- h2 >=4.3,<5
- openssl

about:
homepage: https://github.com/mojoto/req.mojo
Expand All @@ -77,8 +82,9 @@ about:
- vendor/json/NOTICE
summary: A synchronous HTTP client for Mojo.
description: |
Send HTTP/1.1 requests with JSON, forms, authentication, cookies,
connection reuse, streaming, timeouts, and TLS verification.
Send HTTP/1.1 and opt-in HTTP/2 requests with JSON, multipart and file
uploads, HTTP/HTTPS proxies, connection pool limits, hooks, injectable
transports, response iterators, and verified TLS.
Includes the native shared library and the CPU source modules from
ehsanmok/json 0.4.1. The native transport loads automatically from
the active environment; consumers need no extra linker flags.
Expand Down
25 changes: 0 additions & 25 deletions recipes/req/test.mojo

This file was deleted.

63 changes: 22 additions & 41 deletions recipes/req/test.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,24 @@
"""Exercise the installed package using the source release smoke test."""

import os
from pathlib import Path
import subprocess
import threading
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer


class Handler(BaseHTTPRequestHandler):
protocol_version = "HTTP/1.1"

def respond(self, body):
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)

def do_GET(self):
self.respond(b'{"value":42}')

def do_POST(self):
self.respond(self.rfile.read(int(self.headers["Content-Length"])))

def log_message(self, *_):
pass


with ThreadingHTTPServer(("127.0.0.1", 0), Handler) as server:
worker = threading.Thread(target=server.serve_forever, daemon=True)
worker.start()
try:
for command in [["mojo", "run", "--Werror", "test.mojo"], ["./test-req"]]:
subprocess.run(
command,
env={
**os.environ,
"REQ_PACKAGE_TEST_URL": f"http://127.0.0.1:{server.server_port}",
},
check=True,
timeout=120,
)
finally:
server.shutdown()
worker.join()
import sys

sys.path.insert(0, str(Path("tests").resolve()))
from conftest import Fixtures # noqa: E402


with Fixtures() as fixtures:
env = dict(os.environ, **fixtures.environment)
for name in (
"REQ_NATIVE_LIB",
"REQ_EXPECT_LOAD_ERROR",
"REQ_EXPECT_HTTP2_UNAVAILABLE",
):
env.pop(name, None)
for command in [
["mojo", "run", "--Werror", "tests/package.mojo"],
["./test-req"],
]:
subprocess.run(command, env=env, check=True, timeout=120)
Loading