Adding unit tests to WorkflowPlayer.py
This commit is contained in:
34
tests/my_mocks.py
Normal file
34
tests/my_mocks.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
from fasthtml.components import *
|
||||
|
||||
from components.tabs.components.MyTabs import MyTabs
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tabs_manager():
|
||||
class MockTabsManager(MagicMock):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, spec=MyTabs, **kwargs)
|
||||
self.request_new_tab_id = MagicMock(side_effect=["new_tab_id", "new_tab_2", "new_tab_3", StopIteration])
|
||||
self.tabs = {}
|
||||
self.tabs_by_key = {}
|
||||
|
||||
def add_tab(self, title, content, key: str | tuple = None, tab_id: str = None, icon=None):
|
||||
self.tabs[tab_id] = (title, content)
|
||||
self.tabs_by_key[key] = (title, content)
|
||||
|
||||
def set_tab_content(self, tab_id, content, title=None, key: str | tuple = None, active=None):
|
||||
self.tabs[tab_id] = (title, content)
|
||||
self.tabs_by_key[key] = (title, content)
|
||||
|
||||
def refresh(self):
|
||||
return Div(
|
||||
Div(
|
||||
[Div(title) for title in self.tabs.keys()]
|
||||
),
|
||||
list(self.tabs.values())[-1]
|
||||
)
|
||||
|
||||
return MockTabsManager()
|
||||
Reference in New Issue
Block a user