Skip to content

Commit

Permalink
Add testing for parameter exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
airblast-dev committed Mar 13, 2024
1 parent 4dc1dad commit f718704
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions tests/requests/test_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from vshieldpy.api_defs.plans import Plans
from vshieldpy.api_defs.tasks import ServerActions
from vshieldpy.exceptions.parameter_exceptions import (
InvalidDays,
InvalidHostname,
ReinstallWithoutOS,
)
Expand Down Expand Up @@ -54,6 +55,7 @@ async def test_server_manage_autorenew():
async def test_server_update_hostname():
new_hostname = await client.set_server_hostname(0, "SteinsGate")
assert isinstance(new_hostname, str)

with pytest.raises(InvalidHostname):
await client.set_server_hostname(0, str(list(range(0, 20))))

Expand All @@ -72,6 +74,9 @@ async def test_server_renew():
payment = await client.renew_server(0, 100)
assert type(payment) == Payment

with pytest.raises(InvalidDays):
await client.renew_server(0, 366)


async def test_server_delete():
task_id = await client.delete_server(0)
Expand All @@ -83,3 +88,12 @@ async def test_server_order():
Plans.VDS_PRO_GOLD, Locations.US, "Hello", OperatingSystems.Ubuntu20, 10
)
assert type(payment) == Payment

with pytest.raises(InvalidDays):
await client.order_server(
Plans.VDS_PRO_GOLD,
Locations.US,
"darkness",
OperatingSystems.WindowsServer22,
0,
)
6 changes: 5 additions & 1 deletion tests/requests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from vshieldpy.api_defs.auto_renew import AutoRenew
from vshieldpy.api_defs.operating_systems import OperatingSystems
from vshieldpy.api_defs.tasks import ServiceActions
from vshieldpy.exceptions.parameter_exceptions import ReinstallWithoutOS
from vshieldpy.exceptions.parameter_exceptions import InvalidMonths, ReinstallWithoutOS
from vshieldpy.products.service import Hosting

from . import client
Expand Down Expand Up @@ -42,3 +42,7 @@ async def test_service_manage_auto_renew():
async def test_service_renew():
payment = await client.renew_service(1, 3)
assert payment.invoice_id is None

with pytest.raises(InvalidMonths):
# Ignoring the type just for testing purposes.
await client.renew_service(1, 0) # type: ignore

0 comments on commit f718704

Please sign in to comment.