Tests for scaleset size validation
@@ -7,7 +7,7 @@ import unittest
from pydantic import ValidationError
-from onefuzztypes.models import TeamsTemplate
+from onefuzztypes.models import Scaleset, TeamsTemplate
from onefuzztypes.requests import NotificationCreate
@@ -28,5 +28,38 @@ class TestModelsVerify(unittest.TestCase):
NotificationCreate.parse_obj(missing_container)
+class TestScaleset(unittest.TestCase):
+ def test_scaleset_size(self) -> None:
+ with self.assertRaises(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,
+ )
+
+ 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)
+
+ 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()
