Skip to content

Commit a6f0d09

Browse files
committed
fix: codecov
1 parent dcd07bf commit a6f0d09

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/unit/test_program.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import aiohttp
99
import pytest
10+
import typer
1011
from aleph.sdk.conf import settings
1112
from aleph_message.models import Chain
1213

@@ -190,6 +191,39 @@ async def upload_program():
190191
await upload_program()
191192

192193

194+
@pytest.mark.asyncio
195+
async def test_upload_program_reject():
196+
mock_load_account = create_mock_load_account()
197+
mock_account = mock_load_account.return_value
198+
mock_auth_client_class, mock_auth_client = create_mock_auth_client(mock_account)
199+
mock_get_balance = AsyncMock(return_value={"available_amount": 100000})
200+
201+
@patch("aleph_client.commands.program._load_account", mock_load_account)
202+
@patch("aleph_client.utils.os.path.isfile", MagicMock(return_value=True))
203+
@patch("aleph_client.commands.program.AuthenticatedAlephHttpClient", mock_auth_client_class)
204+
@patch("aleph_client.commands.program.get_balance", mock_get_balance)
205+
@patch("aleph_client.commands.program.open", MagicMock())
206+
async def upload_program():
207+
print() # For better display when pytest -v -s
208+
with pytest.raises(typer.Exit) as exc_info:
209+
await upload(
210+
address=FAKE_ADDRESS_EVM,
211+
path=Path("/fake/file.squashfs"),
212+
entrypoint="main:app",
213+
name="mock_program",
214+
runtime=settings.DEFAULT_RUNTIME_ID,
215+
compute_units=6, # Program with more than 4 compute unit should return an error
216+
updatable=True,
217+
skip_volume=True,
218+
skip_env_var=True,
219+
)
220+
mock_load_account.assert_called_once()
221+
mock_auth_client.create_program.assert_called_once()
222+
assert exc_info.value.exit_code == 1
223+
224+
await upload_program()
225+
226+
193227
@pytest.mark.asyncio
194228
async def test_update_program():
195229
mock_load_account = create_mock_load_account()

0 commit comments

Comments
 (0)