From 46064fb70b10e347d70bfa9490688a9d5f8d2a77 Mon Sep 17 00:00:00 2001 From: Anshuman Goel Date: Tue, 3 Nov 2020 08:40:09 -0800 Subject: [PATCH] Tests for scaleset size validation (#243) --- src/pytypes/tests/test_models.py | 35 +++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/pytypes/tests/test_models.py b/src/pytypes/tests/test_models.py index 4001f51f3b..e5d88993d9 100755 --- a/src/pytypes/tests/test_models.py +++ b/src/pytypes/tests/test_models.py @@ -7,7 +7,7 @@ from pydantic import ValidationError -from onefuzztypes.models import TeamsTemplate +from onefuzztypes.models import Scaleset, TeamsTemplate from onefuzztypes.requests import NotificationCreate @@ -28,5 +28,38 @@ def test_model(self) -> None: 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()