Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Tests for scaleset size validation #243

Merged
merged 8 commits into from
Nov 3, 2020
Merged
Changes from 2 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
38 changes: 37 additions & 1 deletion src/pytypes/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from pydantic import ValidationError

from onefuzztypes.models import TeamsTemplate
from onefuzztypes.models import Scaleset, TeamsTemplate
from onefuzztypes.requests import NotificationCreate


Expand All @@ -28,5 +28,41 @@ def test_model(self) -> None:
NotificationCreate.parse_obj(missing_container)


class TestScaleset(unittest.TestCase):
def test_scaleset_size_lt_0(self) -> None:
self.assertRaises(
anshuman-goel marked this conversation as resolved.
Show resolved Hide resolved
ValueError,
Scaleset,
pool_name="test_pool",
vm_sku="Standard_D2ds_v4",
image="Canonical:UbuntuServer:18.04-LTS:latest",
region="westus2",
size=-1,
spot_instances=False,
)

def test_scaleset_size_eq_0(self) -> None:
anshuman-goel marked this conversation as resolved.
Show resolved Hide resolved
scaleset = Scaleset(
pool_name="test_pool",
vm_sku="Standard_D2ds_v4",
image="Canonical:UbuntuServer:18.04-LTS:latest",
region="westus2",
size=0,
spot_instances=False,
)
self.assertEqual(scaleset.size, 0)

def test_scaleset_size_gt_0(self) -> None:
scaleset = Scaleset(
pool_name="test_pool",
vm_sku="Standard_D2ds_v4",
image="Canonical:UbuntuServer:18.04-LTS:latest",
region="westus2",
size=80,
spot_instances=False,
)
self.assertEqual(scaleset.size, 80)


if __name__ == "__main__":
unittest.main()