Skip to content

Commit

Permalink
Add delete to program tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philogicae committed Jan 8, 2025
1 parent 154bb48 commit aca98f8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/unit/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ def create_mock_auth_client(mock_account):
mock_auth_client = AsyncMock(
get_messages=AsyncMock(),
get_message=AsyncMock(return_value=mock_response_get_message),
create_instance=AsyncMock(return_value=[mock_response_create_instance, MagicMock()]),
create_instance=AsyncMock(return_value=[mock_response_create_instance, 200]),
get_program_price=AsyncMock(return_value=MagicMock(required_tokens=0.0001)),
forget=AsyncMock(return_value=(MagicMock(), MagicMock())),
forget=AsyncMock(return_value=(MagicMock(), 200)),
)
mock_auth_client_class = MagicMock()
mock_auth_client_class.return_value.__aenter__ = AsyncMock(return_value=mock_auth_client)
Expand Down
22 changes: 21 additions & 1 deletion tests/unit/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def create_mock_auth_client(mock_account):
get_message=AsyncMock(return_value=mock_response_get_message),
create_store=AsyncMock(return_value=[MagicMock(item_hash=FAKE_STORE_HASH), 200]),
create_program=AsyncMock(return_value=[MagicMock(item_hash=FAKE_PROGRAM_HASH), 200]),
forget=AsyncMock(return_value=(MagicMock(), 200)),
)
mock_auth_client_class = MagicMock()
mock_auth_client_class.return_value.__aenter__ = AsyncMock(return_value=mock_auth_client)
Expand Down Expand Up @@ -153,7 +154,26 @@ async def test_update_program():
async def test_delete_program():
mock_load_account = create_mock_load_account()
mock_account = mock_load_account.return_value
assert True
mock_auth_client_class, mock_auth_client = create_mock_auth_client(mock_account)

@patch("aleph_client.commands.program._load_account", mock_load_account)
@patch("aleph_client.commands.program.AuthenticatedAlephHttpClient", mock_auth_client_class)
async def delete_program():
print() # For better display when pytest -v -s
await delete(
item_hash=FAKE_PROGRAM_HASH,
delete_code=True,
private_key=None,
private_key_file=None,
print_message=False,
verbose=True,
debug=False,
)
mock_load_account.assert_called_once()
assert mock_auth_client.get_message.call_count == 2
assert mock_auth_client.forget.call_count == 2

await delete_program()


@pytest.mark.asyncio
Expand Down

0 comments on commit aca98f8

Please sign in to comment.