Skip to content

Commit

Permalink
Sets up LSP code for a unit test
Browse files Browse the repository at this point in the history
Currently it's not implemented.
  • Loading branch information
skrawcz committed Jul 2, 2024
1 parent 6bb46e0 commit ff6fa33
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 18 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/hamilton-lsp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: LSP Test Workflow

on:
push:
branches:
- main # or any specific branches you want to include
paths:
- 'dev_tools/language_server/**'

pull_request:
paths:
- 'dev_tools/language_server/**'


jobs:
sdk-unit-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
defaults:
run:
working-directory: dev_tools/language_server
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip pytest
pip install -e .
- name: Run unit tests
run: |
pytest tests/
4 changes: 2 additions & 2 deletions dev_tools/language_server/hamilton_lsp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class HamiltonLanguageServer(LanguageServer):
CMD_VIEW_REQUEST = "lsp-view-request"
CMD_VIEW_RESPONSE = "lsp-view-response"

def __init__(self):
super().__init__("HamiltonServer", __version__, max_workers=2)
def __init__(self, server: str = "HamiltonServer", version: str = __version__, loop=None):
super().__init__(server, version, loop=loop, max_workers=2)

self.active_uri: str = ""
self.active_version: str = ""
Expand Down
32 changes: 16 additions & 16 deletions dev_tools/language_server/tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from lsprotocol.types import (
TEXT_DOCUMENT_DOCUMENT_SYMBOL,
DocumentSymbolParams,
TextDocumentIdentifier,
)

# from lsprotocol.types import (
# TEXT_DOCUMENT_DOCUMENT_SYMBOL,
# DocumentSymbolParams,
# TextDocumentIdentifier,
# )

# NOTE Placeholder for a test
def test_something(client_server):
client, _ = client_server
response = client.lsp.send_request(
TEXT_DOCUMENT_DOCUMENT_SYMBOL,
DocumentSymbolParams(
text_document=TextDocumentIdentifier(uri="file://resources/dataflow.py")
),
).result()

assert response
# TODO: add functioning UNIT TEST
# def test_something(client_server):
# client, _ = client_server
# response = client.lsp.send_request(
# TEXT_DOCUMENT_DOCUMENT_SYMBOL,
# DocumentSymbolParams(
# text_document=TextDocumentIdentifier(uri="file://resources/dataflow.py")
# ),
# ).result()
#
# assert response

0 comments on commit ff6fa33

Please sign in to comment.