From bcb2e26f612e3a82651b2c36b6069fa64cd132d7 Mon Sep 17 00:00:00 2001 From: Hostea dashboard Date: Sun, 4 Sep 2022 18:04:37 +0530 Subject: [PATCH] feat: test vm name validation --- dash/tests.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/dash/tests.py b/dash/tests.py index 899adea..52a9c91 100644 --- a/dash/tests.py +++ b/dash/tests.py @@ -30,6 +30,7 @@ from payments import get_payment_model, RedirectNeeded, PaymentStatus from accounts.tests import login_util, register_util from .models import InstanceConfiguration, Instance +from .utils import create_instance, VmErrors, VmException def create_configurations(t: TestCase): @@ -197,6 +198,27 @@ class CreateInstance(TestCase): register_util(t=self, username="createinstance_user") create_configurations(t=self) + @override_settings( + HOSTEA=infra_custom_config(test_name="test_create_instance_util") + ) + def test_create_instance_util(self): + vm_name = "test_create_instance_renders" + configuration = self.instance_config[0].name + + with self.assertRaises(VmException): + create_instance( + vm_name="12345452131324234234234234", + configuration_name=configuration, + user=self.user, + ) + + with self.assertRaises(VmException): + create_instance( + vm_name="122342$#34234", + configuration_name=configuration, + user=self.user, + ) + @override_settings( HOSTEA=infra_custom_config(test_name="test_create_instance_renders") )