Skip to content

Commit

Permalink
Add test for getting non visible items from the database
Browse files Browse the repository at this point in the history
  • Loading branch information
robintw committed Sep 28, 2021
1 parent 61e9be4 commit ec8b780
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/gui_tests/test_gui_methods.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import uuid
from unittest.mock import Mock

import pytest
Expand Down Expand Up @@ -26,6 +27,13 @@ def set_selected_table_to_platform(gui):
gui.get_default_preview_fields()


def set_selected_table_to_nationality(gui):
gui.current_table_object = gui.data_store.db_classes.Nationality
gui.get_column_data(gui.current_table_object)
gui.dropdown_table.text = "Nationalities"
gui.get_default_preview_fields()


def test_generating_column_data(pytestconfig, test_datastore):
if pytestconfig.getoption("capture") != "no":
pytest.skip("Skipped because pytest was not run with -s option")
Expand Down Expand Up @@ -793,3 +801,40 @@ def test_running_query_two_conditions_and(pytestconfig, test_datastore):
assert gui.table_objects[0] is None
assert gui.table_objects[1].name == "ADRI"
assert gui.table_objects[2].name == "JEAN"


def test_selecting_all_table_entries(pytestconfig, test_datastore):
if pytestconfig.getoption("capture") != "no":
pytest.skip("Skipped because pytest was not run with -s option")

gui = MaintenanceGUI(test_datastore)
set_selected_table_to_nationality(gui)

gui.run_query()

# Should be 101 entries because of the header line,
# plus the 100 results
assert len(gui.table_data) == 101
assert len(gui.table_objects) == 101

assert gui.table_data[0] == ["Name", "Priority"]
assert gui.table_data[1] == ["Afghanistan", "None"]

gui.preview_table.current_values = gui.table_objects[1:]
gui.preview_table.non_visible_selected = True

non_vis_entries = gui.get_non_visible_entries_from_database(lambda x: None, lambda x: None)
# Should be 256 - 100
assert len(non_vis_entries) == 156

assert isinstance(non_vis_entries[0], uuid.UUID)

with test_datastore.session_scope():
entries = (
test_datastore.session.query(test_datastore.db_classes.Nationality)
.filter(test_datastore.db_classes.Nationality.nationality_id.in_(non_vis_entries))
.all()
)
names = set([entry.name for entry in entries])

assert "United Kingdom" in names

0 comments on commit ec8b780

Please sign in to comment.