Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
chamini2 committed Oct 21, 2024
1 parent 211c034 commit 77f8cac
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def define_environment(kind: str, **kwargs: Any) -> definitions.EnvironmentDefin

def run_request(
stub: definitions.IsolateStub,
request: definitions.BoundFunction,
request: definitions.BoundFunction | definitions.RunRequest,
*,
build_logs: Optional[List[Log]] = None,
bridge_logs: Optional[List[Log]] = None,
Expand Down Expand Up @@ -270,6 +270,50 @@ def test_user_logs_immediate(stub: definitions.IsolateStub, monkeypatch: Any) ->
assert by_stream[LogLevel.STDERR] == "error error!"


def test_no_stream_logs(stub: definitions.IsolateStub, monkeypatch: Any) -> None:
inherit_from_local(monkeypatch)

env_definition = define_environment("virtualenv", requirements=["pyjokes==0.6.0"])
request = definitions.RunRequest(
function=definitions.BoundFunction(
function=to_serialized_object(
partial(
exec,
textwrap.dedent(
"""
import sys, pyjokes
print(pyjokes.__version__)
print("error error!", file=sys.stderr)
"""
),
),
method="dill",
),
environments=[env_definition],
),
metadata=definitions.TaskMetadata(
logger_labels={},
# the default is True
stream_logs=False,
),
)

user_logs: List[Log] = []
build_logs: List[Log] = []
bridge_logs: List[Log] = []
run_request(
stub,
request,
user_logs=user_logs,
build_logs=build_logs,
bridge_logs=bridge_logs,
)

assert len(user_logs) == 0
assert len(build_logs) == 0
assert len(bridge_logs) == 0


def test_unknown_environment(stub: definitions.IsolateStub, monkeypatch: Any) -> None:
inherit_from_local(monkeypatch)

Expand Down

0 comments on commit 77f8cac

Please sign in to comment.