feat: test vm name validation

wip-gitea
Hostea dashboard 2022-09-04 18:04:37 +05:30
parent 011fb4816f
commit bcb2e26f61
Signed by untrusted user who does not match committer: realaravinth
GPG Key ID: AD9F0F08E855ED88
1 changed files with 22 additions and 0 deletions

View File

@ -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")
)