Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
run: psql --echo-errors --quiet -c '\timing off' -c "CREATE DATABASE ${TEST_DATABASE_NAME};" ${ADMIN_DATABASE_URL}

- name: river migrate-up
run: river migrate-up --database-url "$TEST_DATABASE_URL"
run: river migrate-up --database-url "$TEST_DATABASE_URL" --max-steps 5 # temporarily include max steps so tests can pass with unique fixes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change needed for tests to pass, but should be reverted in #38.


- name: Test
run: rye test
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
run: psql --echo-errors --quiet -c '\timing off' -c "CREATE DATABASE ${DATABASE_NAME};" ${ADMIN_DATABASE_URL}

- name: river migrate-up
run: river migrate-up --database-url "$DATABASE_URL"
run: river migrate-up --database-url "$DATABASE_URL" --max-steps 5 # temporarily include max steps so tests can pass with unique fixes

- name: Run examples
run: rye run python3 -m examples.all
Expand Down
21 changes: 12 additions & 9 deletions tests/client_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from datetime import datetime, timezone
from unittest.mock import MagicMock, Mock, patch
from unittest.mock import MagicMock, patch

import pytest

Expand All @@ -16,17 +16,20 @@ def mock_driver() -> DriverProtocol:

@pytest.fixture
def mock_exec(mock_driver) -> ExecutorProtocol:
def mock_context_manager(val) -> Mock:
context_manager_mock = MagicMock()
context_manager_mock.__enter__.return_value = val
context_manager_mock.__exit__.return_value = Mock()
return context_manager_mock
# Don't try to mock a context manager. It will cause endless pain around the
# edges like swallowing raised exceptions.
class TrivialContextManager:
def __init__(self, with_val):
self.with_val = with_val

# def mock_context_manager(val) -> Mock:
# return Mock(__enter__=val, __exit__=Mock())
def __enter__(self):
return self.with_val

def __exit__(self, exc_type, exc_val, exc_tb):
pass

mock_exec = MagicMock(spec=ExecutorProtocol)
mock_driver.executor.return_value = mock_context_manager(mock_exec)
mock_driver.executor.return_value = TrivialContextManager(mock_exec)

return mock_exec

Expand Down
Loading