Skip to content

Commit

Permalink
feat: python tests github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj319 committed Jan 8, 2025
1 parent 7285ce2 commit f104f82
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
File renamed without changes.
38 changes: 38 additions & 0 deletions .github/workflows/python_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
jobs:
unit:
strategy:
matrix:
python: ['3.12']
os: [ubuntu-latest]
fail-fast: true
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install Dependencies
run: pip install -r requirements.txt

- name: Install the latest version of uv (if required)
uses: astral-sh/setup-uv@v5
with:
version: "latest"

- name: Run Tests
run: uv sync && pytest -s

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exclude = [

[project]
name = "test_locatr"
version = "0.29.0"
version = "0.30.0"
description = "Get HTML/XML elements css/xpath selectors using natural language."
readme = "python_client/README.md"
requires-python = ">=3.9"
Expand Down
5 changes: 3 additions & 2 deletions python_client/tests/test_locatr.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_get_locatr_invalid_json(
@patch("locatr._locatr.Locatr._send_message")
@patch(
"locatr._locatr.Locatr._recv_message",
return_value=b'{"status": "ok", "id": "123e4567-e89b-12d3-a456-426614174000", "type": "initial_handshake", "error": "", "output": ""}',
return_value=b'{"status": "ok", "id": "123e4567-e89b-12d3-a456-426614174000", "type": "initial_handshake", "error": "", "selectors": ["hello"], "selector_type": "xpath"}',
)
def test_get_locatr(
self,
Expand All @@ -107,7 +107,8 @@ def test_get_locatr(
locatr_instance,
):
result = locatr_instance.get_locatr("user request")
assert result == ""
assert result.selectors == ["hello"]
assert result.selector_type == "xpath"
mock_initialize_process_and_socket.assert_called_once()
mock_send_message.assert_called_once()
mock_recv_message.assert_called_once()
Expand Down

0 comments on commit f104f82

Please sign in to comment.