-
Notifications
You must be signed in to change notification settings - Fork 0
UI testing for access store and conversion of ipynb to py #298
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to go to tests/ui
test/ui/test_access_store_ui.py
Outdated
| with open("./ai_lab_secure_configuration_storage.sqlite", "rb") as f: | ||
| data = f.read() | ||
| assert data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can open the file with
https://github.com/exasol/notebook-connector/blob/main/exasol%2Fnb_connector%2Fsecret_store.py#L23
It should open with the password you used to create it.
Furthermore, you need to remove the file at the end of the test. Probably the best is to run the test in a temporary directory. Probably best with the fixture tmp_path and a context for chdir.
Co-authored-by: Torsten Kilias <[email protected]>
Co-authored-by: Torsten Kilias <[email protected]>
test/ui/test_access_store_ui.py
Outdated
|
|
||
| box_element = page_session.locator(":text('Configuration Store')").locator('..').locator('..') | ||
| box_element.wait_for() | ||
| box_element.screenshot() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkilias
box_element.screenshot() - i had to add this line because, the open button is not getting the tick mark,
is this allowed ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least something we might need to investigate, because you're also calling box_element.screenshot() in line 25. A reason why the tick mark is missing could be that there is a slight delay until the tick mark appears. Could replace the box_element.screenshot() in line 23 with a sleep.
test/ui/test_access_store_ui.py
Outdated
| box_element.wait_for() | ||
| box_element.screenshot() | ||
|
|
||
| assert_solara_snapshot(box_element.screenshot()) No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add also the loading of the secret store using https://github.com/exasol/notebook-connector/blob/main/exasol%2Fnb_connector%2Fsecret_store.py#L23
| open_btn.icon = 'check' | ||
| finally: | ||
| # Save the file in the shared store. | ||
| if ipython and hasattr(ipython, 'run_line_magic'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jana-selva added this, because run_line_magic is throwing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a comment that we added this to enable testing.
| sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 | ||
| - name: Tests | ||
| run: poetry run -- pytest -rA --setup-show test/ui/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need matrix for this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how long does the test run?
| assert_screenshot(assert_solara_snapshot, page_session) | ||
| generated_db_file = is_sb_file_exists("ai_lab_secure_configuration_storage.sqlite") | ||
| verify_content(dummy_password, generated_db_file) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added new tests for verifying valid and invalid password. please review the below code.
now working on tmp_path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added monkeypatch to change cwd to tmp_path
| generated_db_file = is_sb_file_exists("ai_lab_secure_configuration_storage.sqlite") | ||
| verify_content(dummy_password, generated_db_file) | ||
|
|
||
| def test_valid_store_password(solara_test, page_session,assert_solara_snapshot,tmp_path,monkeypatch): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def test_valid_store_password(solara_test, page_session,assert_solara_snapshot,tmp_path,monkeypatch): | |
| def test_non_default_store_file(solara_test, page_session,assert_solara_snapshot,tmp_path,monkeypatch): |
| def test_valid_store_password(solara_test, page_session,assert_solara_snapshot,tmp_path,monkeypatch): | ||
| monkeypatch.chdir(tmp_path) | ||
| dummy_password = "dummy123" | ||
| dummy_sb_store_file = "ai_lab_secure_dummy.sqlite" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what does "sb" stand in sb_store_file?
| with pytest.raises(InvalidPassword) as exception: | ||
| dummy_password = "dummy123" | ||
| dummy_sb_store_file = "ai_lab_invalid_dummy.sqlite" | ||
| display(get_access_store_ui()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to create the secret store before you display the UI. We want to test how the UI reacts if you enter the wrong password and not how the secret store reacts.
No description provided.