Skip to content

Commit

Permalink
ci: Add tests to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramimashkouk committed Apr 22, 2024
1 parent c7f5549 commit 90b7242
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/backend_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,36 @@ jobs:
run: |
python -m poetry run isort --line-length=120 --diff .
working-directory: backend/df_designer

test_backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: set up python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: setup poetry and install dependencies
run: |
python -m pip install --upgrade pip poetry
python -m poetry lock --no-update
python -m poetry install --with lint --no-interaction
working-directory: backend/df_designer

- name: build wheel
run: |
python -m poetry build
working-directory: backend/df_designer

- name: Create new project
run: |
python -m poetry run dflowd init --destination ../../ --no-input --overwrite-if-exists
working-directory: backend/df_designer

- name: run tests
run: |
python -m poetry install
python -m poetry run pytest ../backend/df_designer/app/tests/
working-directory: df_designer_project
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ COPY --from=backend-builder /poetry-venv /poetry-venv
ENV PATH="/poetry-venv/bin:$PATH"

# Copy only the necessary files
COPY --from=backend-builder /temp/backend/df_designer /src2/df_designer
COPY --from=backend-builder /temp/backend/df_designer /src2/backend/df_designer
COPY ./${PROJECT_DIR} /src2/${PROJECT_DIR}

# Install the wheel
Expand Down
6 changes: 3 additions & 3 deletions backend/df_designer/app/tests/services/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ async def test_read_stdout(self, run_process):
@pytest.mark.asyncio
async def test_write_stdout(self, run_process):
process = await run_process("cat")
process.write_stdin(b"DF_Designer team welcome you.\n")
await process.write_stdin(b"DF_Designer team welcome you.\n")
output = await process.process.stdout.readline()
assert output.decode().strip() == "DF_Designer team welcome you."


class TestBuildProcess:
pass
# class TestBuildProcess:
# pass
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def test_forward_websocket_messages_to_process(self, mocker, websocket_man
websocket.receive_text = mocker.AsyncMock(side_effect=[awaited_message, None])
run_manager = mocker.MagicMock(spec=RunManager())
run_process = mocker.MagicMock(spec=RunProcess(run_id))
run_process.write_stdin = mocker.MagicMock()
run_process.write_stdin = mocker.AsyncMock()
run_manager.processes = {run_id: run_process}

await websocket_manager.forward_websocket_messages_to_process(run_id, run_manager, websocket)
Expand Down

0 comments on commit 90b7242

Please sign in to comment.