Skip to content

Commit

Permalink
Reinstate reversion of add_relation_unit ValueError to warning (#856)
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoyt authored Nov 27, 2022
1 parent 74ce348 commit 28251fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ops/_private/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def safe_load(stream: Union[str, TextIO]):
def safe_dump(data: Any, *args: Any, encoding: None = None, **kwargs: Any) -> str: ... # noqa
@overload
def safe_dump(data: Any, *args: Any, encoding: str = "", **kwargs: Any) -> bytes: ... # noqa


def safe_dump(data: Any, stream: Optional[Union[str, TextIO]] = None, **kwargs: Any # noqa
) -> Union[str, bytes]:
"""Same as yaml.safe_dump, but use fast C dumper if available.
Expand Down
5 changes: 2 additions & 3 deletions ops/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,11 +789,10 @@ def add_relation_unit(self, relation_id: int, remote_unit_name: str) -> None:
self._backend._relation_data_raw[relation_id][remote_unit_name] = {}
app = cast(model.Application, relation.app) # should not be None since we're testing
if not remote_unit_name.startswith(app.name):
raise ValueError(
warnings.warn(
'Remote unit name invalid: the remote application of {} is called {!r}; '
'the remote unit name should be {}/<some-number>, not {!r}.'
''.format(relation_name, app.name,
app.name, remote_unit_name))
''.format(relation_name, app.name, app.name, remote_unit_name))
app_and_units = self._backend._relation_app_and_units # pyright: ReportPrivateUsage=false
app_and_units[relation_id]["units"].append(remote_unit_name)
# Make sure that the Model reloads the relation_list for this relation_id, as well as
Expand Down

0 comments on commit 28251fa

Please sign in to comment.