Common: Make AWSInstance.is_instance() return boolean

This commit is contained in:
Mike Salvatore 2022-05-09 07:39:05 -04:00
parent 7af03a83f6
commit 7864f48e3c
2 changed files with 4 additions and 4 deletions

View File

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

View File

@ -26,21 +26,21 @@ def patch_fetch_metadata_default_values(patch_fetch_metadata):
def test_is_instance__true(): def test_is_instance__true():
aws_instance = AWSInstance() aws_instance = AWSInstance()
assert aws_instance.is_instance assert aws_instance.is_instance is True
def test_is_instance__false_none(patch_fetch_metadata): def test_is_instance__false_none(patch_fetch_metadata):
patch_fetch_metadata(None, "", "") patch_fetch_metadata(None, "", "")
aws_instance = AWSInstance() aws_instance = AWSInstance()
assert not aws_instance.is_instance assert aws_instance.is_instance is False
def test_is_instance__false_empty_str(patch_fetch_metadata): def test_is_instance__false_empty_str(patch_fetch_metadata):
patch_fetch_metadata("", "", "") patch_fetch_metadata("", "", "")
aws_instance = AWSInstance() aws_instance = AWSInstance()
assert not aws_instance.is_instance assert aws_instance.is_instance is False
def test_instance_id(): def test_instance_id():