Island: Make Machine.operating_system Optional

This commit is contained in:
Mike Salvatore 2022-08-29 15:00:45 -04:00
parent ebcfe5a9fc
commit 694cdca883
2 changed files with 10 additions and 1 deletions

View File

@ -23,7 +23,7 @@ class Machine(MutableInfectionMonkeyBaseModel):
network_interfaces: Sequence[IPv4Interface] network_interfaces: Sequence[IPv4Interface]
"""The machine's networking interfaces""" """The machine's networking interfaces"""
operating_system: OperatingSystem operating_system: Optional[OperatingSystem]
"""The operating system the machine is running""" """The operating system the machine is running"""
operating_system_version: str operating_system_version: str

View File

@ -84,6 +84,15 @@ def test_construct_invalid_field__value_error(key, value):
Machine(**invalid_type_dict) Machine(**invalid_type_dict)
@pytest.mark.parametrize("field", ["hardware_id", "operating_system"])
def test_optional_fields(field):
none_field_dict = MACHINE_SIMPLE_DICT.copy()
none_field_dict[field] = None
# Raises exception_on_failure
Machine(**none_field_dict)
def test_construct__extra_fields_forbidden(): def test_construct__extra_fields_forbidden():
extra_field_dict = MACHINE_SIMPLE_DICT.copy() extra_field_dict = MACHINE_SIMPLE_DICT.copy()
extra_field_dict["extra_field"] = 99 # red balloons extra_field_dict["extra_field"] = 99 # red balloons