-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from canonical/relation-unit-and-app
Upgrade to Relation
- Loading branch information
Showing
13 changed files
with
767 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" | |
[project] | ||
name = "ops-scenario" | ||
|
||
version = "2.1.3.3" | ||
version = "2.1.3.4" | ||
authors = [ | ||
{ name = "Pietro Pasotti", email = "[email protected]" } | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pathlib | ||
from typing import Dict | ||
|
||
from ops.testing import _TestingFilesystem, _TestingStorageMount # noqa | ||
|
||
|
||
# todo consider duplicating the filesystem on State.copy() to be able to diff and have true state snapshots | ||
class _MockStorageMount(_TestingStorageMount): | ||
def __init__(self, location: pathlib.PurePosixPath, src: pathlib.Path): | ||
"""Creates a new simulated storage mount. | ||
Args: | ||
location: The path within simulated filesystem at which this storage will be mounted. | ||
src: The temporary on-disk location where the simulated storage will live. | ||
""" | ||
self._src = src | ||
self._location = location | ||
|
||
try: | ||
# for some reason this fails if src exists, even though exists_ok=True. | ||
super().__init__(location=location, src=src) | ||
except FileExistsError: | ||
pass | ||
|
||
|
||
class _MockFileSystem(_TestingFilesystem): | ||
def __init__(self, mounts: Dict[str, _MockStorageMount]): | ||
super().__init__() | ||
self._mounts = mounts | ||
|
||
def add_mount(self, *args, **kwargs): | ||
raise NotImplementedError("Cannot mutate mounts; declare them all in State.") | ||
|
||
def remove_mount(self, *args, **kwargs): | ||
raise NotImplementedError("Cannot mutate mounts; declare them all in State.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.