Skip to content

Commit

Permalink
Merge pull request #156 from 0Hughman0/shared-tier-gui
Browse files Browse the repository at this point in the history
Shared tier gui
  • Loading branch information
0Hughman0 authored Aug 24, 2024
2 parents c1f77d0 + 6220d55 commit 4a1325e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cassini/sharing.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,25 @@ def find_paths(self) -> List[Path]:
return paths


class SharedTierGui:
"""
Essentially a mock version of TierGui, for use during a shared context.
"""

def __init__(self, stier: SharedTier):
self.stier = stier

def header(self):
print(
"Cassini header cannot gui cannot be used in a shared context - check out cassini to set it up for yourself!"
)

def meta_editor(self, name=None):
print(
"Cassini meta editor cannot be used in a shared context - check out cassini to set it up for yourself!"
)


class SharedTier:
"""
A class that emulates a `TierABC` object without needing a full cassini `Project` configured.
Expand All @@ -353,6 +372,8 @@ def __init__(self, name: str) -> None:
self.shared_project: Union[None, ShareableProject] = None
self.base_path: Union[Path, None] = None
self.meta: Union[Meta, None] = None
self.gui = SharedTierGui(self)

self._accessed: Dict[str, Any] = {}
self._called: Dict[str, Dict[ArgsKwargsType, Any]] = {}

Expand Down
14 changes: 14 additions & 0 deletions tests/test_sharing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
NoseyPath,
SharedTierData,
SharedTier,
SharedTierGui,
SharingTier,
SharedTierCalls,
GetChildCall,
Expand Down Expand Up @@ -388,3 +389,16 @@ def test_getting_tier_children(get_Project, tmp_path):

assert stier_child.exists()
assert (stier_child / 'file').read_text() == 'data'


def test_shared_gui_header():
stier = SharedTier('name')
assert isinstance(stier.gui, SharedTierGui)
assert stier.gui.header() is None


def test_shared_gui_meta_editor():
stier = SharedTier('name')
assert isinstance(stier.gui, SharedTierGui)
assert stier.gui.meta_editor() is None
assert stier.gui.meta_editor(['name']) is None

0 comments on commit 4a1325e

Please sign in to comment.