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

Adding a mock State class that can be instantiated and queried while testing #2101

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

FredLL-Avaiga
Copy link
Member

@FredLL-Avaiga FredLL-Avaiga commented Oct 18, 2024

I had hoped it would not have any impact on the "real" code but it has.
Any discussion is welcome before merge.
resolves #2098

Here is how I think it could be used for tests (aiming at Taipy user developing and testing their app)

The user code to test

def on_action(state: State):
    ...
    state.assign("a", 2)
  • The user test code:
def test_callback():
    ms = MockState(Gui(""), a = 1)
    on_action(ms)
    assert ms.a == 2

…ing tests

I hoped it would not have any impact ont the real code but it has. Any discussion is welcome before merge.
resolves #2098
Copy link
Contributor

github-actions bot commented Oct 18, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
19142 16610 87% 0% 🟢

New Files

File Coverage Status
taipy/mock/init.py 100% 🟢
taipy/mock/gui/init.py 100% 🟢
taipy/mock/gui/mock_state.py 100% 🟢
TOTAL 100% 🟢

Modified Files

File Coverage Status
taipy/gui/gui.py 80% 🟢
taipy/gui/state.py 87% 🟢
TOTAL 83% 🟢

updated for commit: 4eca54f by action🐍

@FredLL-Avaiga FredLL-Avaiga marked this pull request as ready for review October 18, 2024 21:45
more tests
@FredLL-Avaiga FredLL-Avaiga changed the title Adding a testing State class that can be instantiated and queried while testing Adding a mack State class that can be instantiated and queried while testing Oct 19, 2024
@FredLL-Avaiga FredLL-Avaiga changed the title Adding a mack State class that can be instantiated and queried while testing Adding a mock State class that can be instantiated and queried while testing Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gui: Back-End ✨New feature 🟨 Priority: Medium Not blocking but should be addressed 📝Release Notes Impacts the Release Notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit testing with State mock-up
1 participant