Skip to content

Commit

Permalink
Merge branch 'main' into improve-logging
Browse files Browse the repository at this point in the history
Signed-off-by: ff137 <[email protected]>
  • Loading branch information
ff137 committed Nov 27, 2024
2 parents 35e6445 + 27edc6e commit 79c58f2
Show file tree
Hide file tree
Showing 102 changed files with 8,169 additions and 6,089 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
- name: Ruff Format and Lint Check
uses: chartboost/ruff-action@v1
with:
version: 0.5.7
version: 0.8.0
args: "format --check"
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
repos:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.16.0
rev: v9.18.0
hooks:
- id: commitlint
stages: [commit-msg]
args: ["--config", ".commitlint.config.js"]
additional_dependencies: ['@commitlint/config-conventional']
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ensure this is synced with pyproject.toml
rev: v0.5.7
rev: v0.8.0
hooks:
# Run the linter
- id: ruff
Expand Down
18 changes: 8 additions & 10 deletions acapy_agent/commands/tests/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@

class TestHelp(IsolatedAsyncioTestCase):
def test_exec_help(self):
with mock.patch.object(
command.ArgumentParser, "print_help"
) as mock_print_help, mock.patch(
"builtins.print", mock.MagicMock()
) as mock_print:
with (
mock.patch.object(command.ArgumentParser, "print_help") as mock_print_help,
mock.patch("builtins.print", mock.MagicMock()) as mock_print,
):
command.execute([])
mock_print_help.assert_called_once()

command.execute(["-v"])
mock_print.assert_called_once_with(command.__version__)

def test_main(self):
with mock.patch.object(
command, "__name__", "__main__"
) as mock_name, mock.patch.object(
command, "execute", mock.MagicMock()
) as mock_execute:
with (
mock.patch.object(command, "__name__", "__main__") as mock_name,
mock.patch.object(command, "execute", mock.MagicMock()) as mock_execute,
):
command.main()
mock_execute.assert_called_once
43 changes: 24 additions & 19 deletions acapy_agent/commands/tests/test_provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ def test_bad_calls(self):

async def test_provision_ledger_configured(self):
profile = mock.MagicMock(close=mock.CoroutineMock())
with mock.patch.object(
test_module,
"wallet_config",
mock.CoroutineMock(
return_value=(
profile,
mock.CoroutineMock(did="public DID", verkey="verkey"),
)
with (
mock.patch.object(
test_module,
"wallet_config",
mock.CoroutineMock(
return_value=(
profile,
mock.CoroutineMock(did="public DID", verkey="verkey"),
)
),
),
mock.patch.object(
test_module, "ledger_config", mock.CoroutineMock(return_value=True)
),
), mock.patch.object(
test_module, "ledger_config", mock.CoroutineMock(return_value=True)
):
await test_module.provision({})

Expand All @@ -44,9 +47,10 @@ async def test_provision_config_x(self):
await test_module.provision({})

def test_main(self):
with mock.patch.object(test_module, "__name__", "__main__"), mock.patch.object(
test_module, "execute", mock.MagicMock()
) as mock_execute:
with (
mock.patch.object(test_module, "__name__", "__main__"),
mock.patch.object(test_module, "execute", mock.MagicMock()) as mock_execute,
):
test_module.main()
mock_execute.assert_called_once

Expand All @@ -55,12 +59,13 @@ async def test_provision_should_store_provided_mediation_invite(self):
mediation_invite = "test-invite"
test_profile = await create_test_profile()

with mock.patch.object(
test_module.MediationInviteStore, "store"
) as invite_store, mock.patch.object(
test_module,
"wallet_config",
mock.CoroutineMock(return_value=(test_profile, mock.MagicMock())),
with (
mock.patch.object(test_module.MediationInviteStore, "store") as invite_store,
mock.patch.object(
test_module,
"wallet_config",
mock.CoroutineMock(return_value=(test_profile, mock.MagicMock())),
),
):
# when
await test_module.provision({"mediation.invite": mediation_invite})
Expand Down
51 changes: 25 additions & 26 deletions acapy_agent/commands/tests/test_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,23 @@ async def test_start_shutdown_app(self):
await test_module.shutdown_app(mock_conductor)

def test_exec_start(self):
with mock.patch.object(
# Normally this would be a CoroutineMock. However, it is awaited by
# run_loop, which is mocked out. So we mock it as a MagicMock.
test_module,
"start_app",
mock.MagicMock(),
) as start_app, mock.patch.object(
test_module, "run_loop"
) as run_loop, mock.patch.object(
# Same here as note above
test_module,
"shutdown_app",
mock.MagicMock(),
) as shutdown_app, mock.patch.object(
test_module, "uvloop", mock.MagicMock()
) as mock_uvloop:
with (
mock.patch.object(
# Normally this would be a CoroutineMock. However, it is awaited by
# run_loop, which is mocked out. So we mock it as a MagicMock.
test_module,
"start_app",
mock.MagicMock(),
) as start_app,
mock.patch.object(test_module, "run_loop") as run_loop,
mock.patch.object(
# Same here as note above
test_module,
"shutdown_app",
mock.MagicMock(),
) as shutdown_app,
mock.patch.object(test_module, "uvloop", mock.MagicMock()) as mock_uvloop,
):
mock_uvloop.install = mock.MagicMock()
test_module.execute(
[
Expand Down Expand Up @@ -102,11 +103,10 @@ async def test_run_loop_init_x(self):
startup_call = startup()
shutdown = mock.CoroutineMock()
shutdown_call = shutdown()
with mock.patch.object(
test_module, "asyncio", autospec=True
) as mock_asyncio, mock.patch.object(
test_module, "LOGGER", autospec=True
) as mock_logger:
with (
mock.patch.object(test_module, "asyncio", autospec=True) as mock_asyncio,
mock.patch.object(test_module, "LOGGER", autospec=True) as mock_logger,
):
test_module.run_loop(startup_call, shutdown_call)
mock_add = mock_asyncio.get_event_loop.return_value.add_signal_handler
mock_add.assert_called_once()
Expand Down Expand Up @@ -135,10 +135,9 @@ async def test_run_loop_init_x(self):
mock_logger.exception.assert_called_once()

def test_main(self):
with mock.patch.object(
test_module, "__name__", "__main__"
) as mock_name, mock.patch.object(
test_module, "execute", mock.MagicMock()
) as mock_execute:
with (
mock.patch.object(test_module, "__name__", "__main__") as mock_name,
mock.patch.object(test_module, "execute", mock.MagicMock()) as mock_execute,
):
test_module.main()
mock_execute.assert_called_once
Loading

0 comments on commit 79c58f2

Please sign in to comment.