Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added JLGui tests #143

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions tests/test_jlgui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from unittest.mock import Mock


from cassini import DEFAULT_TIERS, FolderTierBase, NotebookTierBase
import cassini.jlgui
from cassini.jlgui import JLGui
from cassini.testing_utils import patch_project, get_Project


def test_defaults_have_jl_gui():
for Tier in DEFAULT_TIERS:
assert Tier.gui_cls is JLGui


def test_folder_inherited_have_jl_gui():
class Tier(FolderTierBase):
pass

assert Tier.gui_cls is JLGui


def test_notebook_tier_inherited_have_jlgui():
class Tier(NotebookTierBase):
pass

assert Tier.gui_cls is JLGui


def test_gui_instance_made(patch_project):
Tier, Project = patch_project
tier1 = Project['Tier1']
assert isinstance(tier1.gui, JLGui)


def test_gui_instance_passed_tier(patch_project):
Tier, Project = patch_project
tier1 = Project['Tier1']
assert tier1.gui.tier is tier1


def test_gui_header(monkeypatch):
mock = Mock()
monkeypatch.setattr(cassini.jlgui, 'publish_display_data', mock)
gui = JLGui(None)
gui.header()
assert mock.called_with({"application/cassini.header+json": {}})


def test_meta_editor_single_key(monkeypatch):
mock = Mock()
monkeypatch.setattr(cassini.jlgui, 'publish_display_data', mock)
gui = JLGui(None)
gui.meta_editor('key')
assert mock.call_args.args == ({"application/cassini.metaeditor+json": {"values": ["key"]}},)


def test_meta_editor_multi_key(monkeypatch):
mock = Mock()
monkeypatch.setattr(cassini.jlgui, 'publish_display_data', mock)
gui = JLGui(None)
gui.meta_editor(['key1', 'key2'])
assert mock.call_args.args == ({"application/cassini.metaeditor+json": {"values": ['key1', 'key2']}},)
Loading