def test_get_headers_dict() -> None: """ This test verifies that the correct headers dictionary is returned for the given status. """ # create the test object and get the actual test values this: _ContainerStatus = _ContainerStatus(expected_running_dict) actual_headers_dict: Dict[Text, Text] = this.get_headers_dict() # verify actual values match the expected values assert isinstance(actual_headers_dict, dict) assert len(actual_headers_dict) == 7 assert actual_headers_dict["container-name"] == expected_running_dict[ "name"] assert actual_headers_dict["container-image"] == expected_running_dict[ "image"] assert actual_headers_dict["container-is-started"] == str( expected_running_dict["started"]) assert actual_headers_dict["container-is-ready"] == str( expected_running_dict["ready"]) assert actual_headers_dict["container-restarts"] == str( expected_running_dict["restartCount"]) assert actual_headers_dict["container-state"] == "running" assert actual_headers_dict[ "container-started-at"] == expected_running_dict["state"]["running"][ "startedAt"]
def test_is_started_missing() -> None: """ This test verifies that an empty string is returned if the started value is not defined. """ # create the test object this: _ContainerStatus = _ContainerStatus(dict()) # verify actual value matches the expected value assert this.is_started() == ""
def test_is_started() -> None: """ This test verifies that the started value is correctly returned for the given container status. """ # create the test object this: _ContainerStatus = _ContainerStatus(expected_running_dict) # verify actual value matches the expected value assert this.is_started() == str(expected_running_dict["started"])
def test_get_name() -> None: """ This test verifies that the name value is correctly returned for the given container status. """ # create the test object this: _ContainerStatus = _ContainerStatus(expected_running_dict) # verify actual value matches the expected value assert this.get_name() == expected_running_dict["name"]
def test_get_state_dict_missing() -> None: """ This test verifies that the correct state dictionary is returned when the container state is not defined. """ # create the test object and get the actual test values this: _ContainerStatus = _ContainerStatus(dict()) actual_state_dict: Dict[Text, Text] = this.get_state_dict() # verify actual values match the expected values assert actual_state_dict is not None assert isinstance(actual_state_dict, dict) assert len(actual_state_dict) == 0
def test_get_state_dict_running() -> None: """ This test verifies that the correct state dictionary is returned when the container is in the "running" state. """ # create the test object and get the actual test values this: _ContainerStatus = _ContainerStatus(expected_running_dict) actual_state_dict: Dict[Text, Text] = this.get_state_dict() # verify actual values match the expected values assert isinstance(actual_state_dict, dict) assert len(actual_state_dict) == 2 assert actual_state_dict["container-state"] == "running" assert actual_state_dict["container-started-at"] == expected_running_dict[ "state"]["running"]["startedAt"]
def test_get_headers_dict_missing() -> None: """ This test verifies that the correct headers dictionary is returned when the status dictionary is undefined. """ # create the test object and get the actual test values this: _ContainerStatus = _ContainerStatus(dict()) actual_headers_dict: Dict[Text, Text] = this.get_headers_dict() # verify actual values match the expected values assert isinstance(actual_headers_dict, dict) assert len(actual_headers_dict) == 5 assert actual_headers_dict["container-name"] == "" assert actual_headers_dict["container-image"] == "" assert actual_headers_dict["container-is-started"] == "" assert actual_headers_dict["container-is-ready"] == "" assert actual_headers_dict["container-restarts"] == ""
def test_get_state_dict_terminated() -> None: """ This test verifies that the correct state dictionary is returned when the container is in the "terminated" state. """ # create the test object and get the actual test values this: _ContainerStatus = _ContainerStatus(expected_terminated_dict) actual_state_dict: Dict[Text, Text] = this.get_state_dict() # verify actual values match the expected values assert isinstance(actual_state_dict, dict) assert len(actual_state_dict) == 4 assert actual_state_dict["container-state"] == "terminated" assert actual_state_dict[ "container-state-reason"] == expected_terminated_dict["state"][ "terminated"]["reason"] assert actual_state_dict[ "container-started-at"] == expected_terminated_dict["state"][ "terminated"]["startedAt"] assert actual_state_dict[ "container-finished-at"] == expected_terminated_dict["state"][ "terminated"]["finishedAt"]