Spaces:
Sleeping
Sleeping
Download backend/visual_notebook/tests/test_operations.py from Sid-WC121/visual-notebook: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/Sid-WC121/visual-notebook/resolve/main/backend/visual_notebook/tests/test_operations.py
- Command line
-
hf download hf://spaces/Sid-WC121/visual-notebook/backend/visual_notebook/tests/test_operations.py
-
curl -L -o test_operations.py https://huggingface.co/spaces/Sid-WC121/visual-notebook/resolve/main/backend/visual_notebook/tests/test_operations.py
1.13 kB
| """Tests for operations module.""" | |
| import pytest | |
| from visual_notebook.domain.operations import OPERATIONS | |
| def test_operations_registry(): | |
| assert "filter" in OPERATIONS | |
| assert "sort" in OPERATIONS | |
| assert "select" in OPERATIONS | |
| assert "rename" in OPERATIONS | |
| assert "groupby" in OPERATIONS | |
| assert "fill_nulls" in OPERATIONS | |
| assert "clip" in OPERATIONS | |
| def test_filter_validation(): | |
| op = OPERATIONS["filter"] | |
| with pytest.raises(ValueError): | |
| op.validate({}, []) | |
| with pytest.raises(ValueError): | |
| op.validate({"column": "x"}, [{"name": "y", "dtype": "VARCHAR"}]) | |
| result = op.validate({"column": "x", "operator": "eq", "value": 1}, [{"name": "x", "dtype": "INTEGER"}]) | |
| assert result["column"] == "x" | |
| def test_sort_validation(): | |
| op = OPERATIONS["sort"] | |
| result = op.validate({"column": "x"}, []) | |
| assert result["descending"] is False | |
| def test_select_validation(): | |
| op = OPERATIONS["select"] | |
| with pytest.raises(ValueError): | |
| op.validate({}, []) | |
| result = op.validate({"columns": ["a", "b"]}, []) | |
| assert result["columns"] == ["a", "b"] | |