Skip to content

Commit

Permalink
ci: fix pre-commit failure
Browse files Browse the repository at this point in the history
  • Loading branch information
hetangmodi-crest committed Nov 21, 2024
1 parent f6034d6 commit d0de070
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/unit/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
from selenium.webdriver.common.by import By
from pytest_splunk_addon_ui_smartx.components.table import Table


@pytest.fixture
def mock_table():
mock_browser = MagicMock()

# Mocking container with a `select` attribute
mock_container = MagicMock()
mock_container.select = "#test-container"
table = Table(mock_browser, mock_container)
return table


@patch("pytest_splunk_addon_ui_smartx.components.table.Table._get_row")
def test_get_more_info_expand_row_false(mock_get_row, mock_table):
mock_row = MagicMock()
Expand All @@ -25,7 +27,7 @@ def test_get_more_info_expand_row_false(mock_get_row, mock_table):
mock_table.get_more_info(name="Test Row", cancel=False, expand_row=False)

mock_get_row.assert_called_with("Test Row")
mock_row.find_element.assert_not_called()
mock_row.find_element.assert_not_called()
mock_more_info_element.click.assert_not_called()


Expand All @@ -38,7 +40,7 @@ def test_get_more_info_expand_row_true(mock_get_row, mock_table):
mock_row.find_element.return_value = mock_more_info_element

mock_key1 = MagicMock()
mock_key1.get_attribute.return_value = " Key1 "
mock_key1.get_attribute.return_value = " Key1 "
mock_key2 = MagicMock()
mock_key2.get_attribute.return_value = " Key2 "

Expand All @@ -51,10 +53,10 @@ def test_get_more_info_expand_row_true(mock_get_row, mock_table):
[mock_key1, mock_key2],
[mock_value1, mock_value2],
]

# Call the function with expand_row=True and cancel=False as we are testing for expand_row parameter
result = mock_table.get_more_info(name="Test Row", cancel=False, expand_row=True)

mock_get_row.assert_called_with("Test Row")
mock_more_info_element.click.assert_called_once()
assert result == {"Key1": "Value1", "Key2": "Value2"}
assert result == {"Key1": "Value1", "Key2": "Value2"}

0 comments on commit d0de070

Please sign in to comment.