Island: Add default value for Machine.hostname

This commit is contained in:
Mike Salvatore 2022-08-29 20:27:57 -04:00
parent 5d51b40475
commit ac1cda40a8
2 changed files with 10 additions and 1 deletions

View File

@ -29,7 +29,7 @@ class Machine(MutableInfectionMonkeyBaseModel):
operating_system_version: str = Field(default="")
"""The specific version of the operating system the machine is running"""
hostname: str
hostname: str = Field(default="")
"""The hostname of the machine"""
_make_immutable_sequence = validator("network_interfaces", pre=True, allow_reuse=True)(

View File

@ -194,3 +194,12 @@ def test_set_hostname():
# Raises exception_on_failure
m.operating_system_version = "wopr"
def test_hostname_default_value():
missing_hostname_dict = MACHINE_OBJECT_DICT.copy()
del missing_hostname_dict["hostname"]
m = Machine(**missing_hostname_dict)
assert m.hostname == ""