Common: Set AWSInstance.is_instance to False if empty string

This commit is contained in:
Mike Salvatore 2022-05-06 04:07:40 -04:00
parent 09218ef3d3
commit ca38235b8e
2 changed files with 9 additions and 2 deletions

View File

@ -34,7 +34,7 @@ class AWSInstance:
@property
def is_instance(self) -> bool:
self._wait_for_initialization_to_complete()
return self._instance_id is not None
return self._instance_id
@property
def instance_id(self) -> str:

View File

@ -29,13 +29,20 @@ def test_is_instance__true():
assert aws_instance.is_instance
def test_is_instance__false(patch_fetch_metadata):
def test_is_instance__false_none(patch_fetch_metadata):
patch_fetch_metadata(None, "", "")
aws_instance = AWSInstance()
assert not aws_instance.is_instance
def test_is_instance__false_empty_str(patch_fetch_metadata):
patch_fetch_metadata("", "", "")
aws_instance = AWSInstance()
assert not aws_instance.is_instance
def test_instance_id():
aws_instance = AWSInstance()