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 ba97ef5
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
from functools import partial
from pathlib import Path
from typing import Any, Iterator, List, Optional, cast
from typing import Any, Iterator, List, Optional, Union, cast

import grpc
import pytest
Expand Down 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: Union[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 ba97ef5

Please sign in to comment.