Skip to content

Commit

Permalink
TST: add test_apply_filter for search_page
Browse files Browse the repository at this point in the history
  • Loading branch information
tangkong committed Jul 26, 2024
1 parent 64fcd6e commit 0009143
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
12 changes: 12 additions & 0 deletions superscore/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,3 +720,15 @@ def done(self):
def mock_client(mock_backend: _Backend) -> Client:
client = Client(backend=mock_backend)
return client


@pytest.fixture(scope='function')
def sample_client(
filestore_backend: FilestoreBackend,
dummy_cl: ControlLayer
) -> Client:
"""Return a client with actula data, but no communication capabilities"""
client = Client(backend=filestore_backend)
client.cl = dummy_cl

return client
31 changes: 29 additions & 2 deletions superscore/tests/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def collection_page(qtbot: QtBot):


@pytest.fixture(scope='function')
def search_page(qtbot: QtBot, mock_client: Client):
page = SearchPage(client=mock_client)
def search_page(qtbot: QtBot, sample_client: Client):
page = SearchPage(client=sample_client)
qtbot.addWidget(page)
return page

Expand All @@ -28,3 +28,30 @@ def search_page(qtbot: QtBot, mock_client: Client):
def test_page_smoke(page: str, request: pytest.FixtureRequest):
"""smoke test, just create each page and see if they fail"""
print(type(request.getfixturevalue(page)))


def test_apply_filter(search_page: SearchPage):
search_page.apply_filter_button.clicked.emit()
assert search_page.results_table_view.model().rowCount() == 6

search_page.snapshot_checkbox.setChecked(False)
search_page.apply_filter_button.clicked.emit()
assert search_page.results_table_view.model().rowCount() == 5

search_page.readback_checkbox.setChecked(False)
search_page.apply_filter_button.clicked.emit()
assert search_page.results_table_view.model().rowCount() == 2

search_page.setpoint_checkbox.setChecked(False)
search_page.apply_filter_button.clicked.emit()
assert search_page.results_table_view.model().rowCount() == 1

# reset and try name filter
for box in search_page.type_checkboxes:
box.setChecked(True)
search_page.apply_filter_button.clicked.emit()
assert search_page.results_table_view.model().rowCount() == 6

search_page.name_line_edit.setText('collection 1')
search_page.apply_filter_button.clicked.emit()
assert search_page.results_table_view.model().rowCount() == 1

0 comments on commit 0009143

Please sign in to comment.