Skip to content

Commit

Permalink
No upper limit on MAX_FRAME_SIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Dec 6, 2024
1 parent 4a3fb1b commit 9342027
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
3 changes: 1 addition & 2 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ the current working directory.

### `--juju-max-frame-size`

Maximum frame size to use when connecting to a juju model. The default is None and
the value must be between 0 and MAX_FRAME_SIZE
Maximum frame size to use when connecting to a juju model. The default is None


## Fixtures
Expand Down
9 changes: 3 additions & 6 deletions pytest_operator/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import yaml
from _pytest.config import Config
from _pytest.config.argparsing import Parser
from juju.client import client, connection
from juju.client import client
from juju.client.jujudata import FileJujuData
from juju.errors import JujuError
from juju.exceptions import DeadEntityException
Expand Down Expand Up @@ -427,13 +427,10 @@ def _connect_kwds(request) -> Dict[str, Any]:
"""Create a dict of keyword arguments for connecting to a model."""
kwds = {}
if val := request.config.option.juju_max_frame_size:
if 0 < val <= connection.Connection.MAX_FRAME_SIZE:
if 0 < val:
kwds["max_frame_size"] = val
else:
raise ValueError(
f"max-frame-size must be positive int and less than or equal to "
f"{connection.Connection.MAX_FRAME_SIZE}"
)
raise ValueError(f"max-frame-size must be positive integer, not {val}")
return kwds


Expand Down
7 changes: 2 additions & 5 deletions tests/unit/test_pytest_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,9 @@ async def test_fixture_set_up_existing_model(
assert len(ops_test.models) == 1


@pytest.mark.parametrize("max_frame_size", [-1, 2**32])
async def test_fixture_invalid_max_frame_size(
setup_request, tmp_path_factory, max_frame_size
):
async def test_fixture_invalid_max_frame_size(setup_request, tmp_path_factory):
setup_request.config.option.model = "this-model"
setup_request.config.option.juju_max_frame_size = max_frame_size
setup_request.config.option.juju_max_frame_size = -1
with pytest.raises(ValueError):
plugin.OpsTest(setup_request, tmp_path_factory)

Expand Down

0 comments on commit 9342027

Please sign in to comment.