A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
test: test out of bounds page and offset in table tests (#2259)
Myles Scolnickd4733f3ac9c6
diff --git a/tests/_plugins/ui/_impl/tables/test_default_table.py b/tests/_plugins/ui/_impl/tables/test_default_table.pyindex 82e94a901e..75c9f98d0f 100644--- a/tests/_plugins/ui/_impl/tables/test_default_table.py+++ b/tests/_plugins/ui/_impl/tables/test_default_table.py@@ -63,6 +63,15 @@ class TestDefaultTable(unittest.TestCase):]assert limited_manager.data == expected_data+ def test_take_out_of_bounds(self) -> None:+ # Too large of page+ limited_manager = self.manager.take(10, 0)+ assert limited_manager.data == self.data++ # Too large of page and offset+ limited_manager = self.manager.take(10, 10)+ assert limited_manager.data == []+def test_sort(self) -> None:sorted_data = self.manager.sort_values(by="name", descending=True).dataexpected_data = [@@ -309,6 +318,16 @@ class TestColumnarDefaultTable(unittest.TestCase):}assert limited_manager.data == expected_data+ def test_take_out_of_bounds(self) -> None:+ # Too large of page+ limited_manager = self.manager.take(10, 0)+ assert limited_manager.data == self.data++ # Too large of page and offset+ limited_manager = self.manager.take(10, 10)+ assert limited_manager.data["age"] == []+ assert limited_manager.data["name"] == []+def test_sort(self) -> None:sorted_data = self.manager.sort_values(by="name", descending=True).dataexpected_data = [@@ -509,6 +528,18 @@ class TestDictionaryDefaultTable(unittest.TestCase):limited_manager = self.manager.take(1, 0)assert limited_manager.data == [{"key": "a", "value": 1}]+ def test_take_out_of_bounds(self) -> None:+ # Too large of page+ limited_manager = self.manager.take(10, 0)+ assert limited_manager.data == [+ {"key": "a", "value": 1},+ {"key": "b", "value": 2},+ ]++ # Too large of page and offset+ limited_manager = self.manager.take(10, 10)+ assert limited_manager.data == []+def test_sort(self) -> None:sorted_manager = self.manager.sort_values(by="value", descending=True)expected_data = [{"key": "b", "value": 2}, {"key": "a", "value": 1}]diff --git a/tests/_plugins/ui/_impl/tables/test_df_protocol.py b/tests/_plugins/ui/_impl/tables/test_df_protocol.pyindex 11077d061a..ca5aaebf03 100644--- a/tests/_plugins/ui/_impl/tables/test_df_protocol.py+++ b/tests/_plugins/ui/_impl/tables/test_df_protocol.py@@ -111,6 +111,13 @@ class TestDataFrameProtocolTableManager(unittest.TestCase):expected_data = self.data.take([0])assert limited_manager.data == expected_data+ def test_take_out_of_bounds(self) -> None:+ # Too large of page+ assert self.manager.take(10, 0).data == self.data++ # Too large of page and offset+ assert len(self.manager.take(10, 10).data) == 0+def test_summary_integer(self) -> None:column = "A"summary = self.manager.get_summary(column)diff --git a/tests/_plugins/ui/_impl/tables/test_pandas_table.py b/tests/_plugins/ui/_impl/tables/test_pandas_table.pyindex 79a29b47c9..f6bbb5f7dc 100644--- a/tests/_plugins/ui/_impl/tables/test_pandas_table.py+++ b/tests/_plugins/ui/_impl/tables/test_pandas_table.py@@ -240,6 +240,14 @@ class TestPandasTableManager(unittest.TestCase):expected_data = self.data.head(limit)pd.testing.assert_frame_equal(limited_manager.data, expected_data)+ def test_take_out_of_bounds(self) -> None:+ # Too large of page+ assert len(self.manager.take(10, 0).data) == 3+ assert len(self.data) == 3++ # Too large of page and offset+ assert len(self.manager.take(10, 10).data) == 0+def test_summary_integer(self) -> None:column = "A"summary = self.manager.get_summary(column)diff --git a/tests/_plugins/ui/_impl/tables/test_polars_table.py b/tests/_plugins/ui/_impl/tables/test_polars_table.pyindex 854cb4ff5a..9105716fea 100644--- a/tests/_plugins/ui/_impl/tables/test_polars_table.py+++ b/tests/_plugins/ui/_impl/tables/test_polars_table.py@@ -215,6 +215,14 @@ class TestPolarsTableManagerFactory(unittest.TestCase):expected_data = self.data.head(1)assert limited_manager.data.equals(expected_data)+ def test_take_out_of_bounds(self) -> None:+ # Too large of page+ assert len(self.manager.take(10, 0).data) == 3+ assert len(self.data) == 3++ # Too large of page and offset+ assert self.manager.take(10, 10).data.is_empty()+def test_summary_integer(self) -> None:column = "A"summary = self.manager.get_summary(column)diff --git a/tests/_plugins/ui/_impl/tables/test_pyarrow.py b/tests/_plugins/ui/_impl/tables/test_pyarrow.pyindex b048303ceb..47427608cd 100644--- a/tests/_plugins/ui/_impl/tables/test_pyarrow.py+++ b/tests/_plugins/ui/_impl/tables/test_pyarrow.py@@ -116,6 +116,13 @@ class TestPyArrowTableManagerFactory(unittest.TestCase):expected_data = self.data.take([0])assert limited_manager.data == expected_data+ def test_take_out_of_bounds(self) -> None:+ # Too large of page+ assert self.manager.take(10, 0).data == self.data++ # Too large of page and offset+ assert len(self.manager.take(10, 10).data) == 0+def test_limit_more_than_num_rows(self) -> None:limited_manager = self.manager.take(500, 0)assert limited_manager.data == self.data@@ -372,6 +379,13 @@ class TestPyArrowRecordBatchManagerFactory(unittest.TestCase):expected_data = self.data.slice(0, 1)assert limited_manager.data == expected_data+ def test_take_out_of_bounds(self) -> None:+ # Too large of page+ assert self.manager.take(10, 0).data == self.data++ # Too large of page and offset+ assert len(self.manager.take(10, 10).data) == 0+def test_limit_more_than_num_rows(self) -> None:limited_manager = self.manager.take(500, 0)assert limited_manager.data == self.data