Skip to content

Commit

Permalink
Clean up AgentStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
osoriano committed Feb 26, 2025
1 parent e364b00 commit 72eb2de
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 83 deletions.
63 changes: 0 additions & 63 deletions deploy-agent/deployd/types/agent_status.py

This file was deleted.

9 changes: 1 addition & 8 deletions deploy-agent/deployd/types/ping_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from deployd.types.agent_status import AgentStatus


class PingReport(object):
def __init__(self, jsonValue=None) -> None:
Expand All @@ -38,12 +36,7 @@ def __init__(self, jsonValue=None) -> None:
self.deployId = jsonValue.get("deployId")
self.envId = jsonValue.get("envId")
self.deployStage = jsonValue.get("deployStage")

if isinstance(jsonValue.get("status"), int):
self.status = AgentStatus._VALUES_TO_NAMES[jsonValue.get("status")]
else:
self.status = jsonValue.get("status")

self.status = jsonValue.get("status")
self.envName = jsonValue.get("envName")
self.stageName = jsonValue.get("stageName")
self.stageType = jsonValue.get("stageType")
Expand Down
8 changes: 1 addition & 7 deletions deploy-agent/deployd/types/ping_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import json
from deployd.types.agent_status import AgentStatus


class PingRequest(object):
Expand Down Expand Up @@ -77,12 +76,7 @@ def to_json(self):
ping_report["deployId"] = report.deployId
ping_report["envId"] = report.envId
ping_report["deployStage"] = report.deployStage

if isinstance(report.status, int):
ping_report["agentStatus"] = AgentStatus._VALUES_TO_NAMES[report.status]
else:
ping_report["agentStatus"] = report.status

ping_report["agentStatus"] = report.status
ping_report["errorCode"] = report.errorCode
ping_report["errorMessage"] = report.errorMessage
ping_report["failCount"] = report.failCount
Expand Down
6 changes: 3 additions & 3 deletions deploy-agent/tests/unit/deploy/types/test_ping_report.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from deployd.common.types import DeployStage
from deployd.common.types import AgentStatus, DeployStage
from deployd.types.ping_report import PingReport
import unittest

Expand All @@ -8,7 +8,7 @@ def test_init_enums(self):
report = PingReport(
jsonValue={
"deployStage": DeployStage.UNKNOWN,
"status": 0,
"status": AgentStatus.SUCCEEDED,
}
)
self.assertEqual(report.deployStage, "UNKNOWN")
Expand All @@ -17,7 +17,7 @@ def test_init_enums(self):
report = PingReport(
jsonValue={
"deployStage": DeployStage.STOPPED,
"status": 7,
"status": AgentStatus.TOO_MANY_RETRY,
}
)
self.assertEqual(report.deployStage, "STOPPED")
Expand Down
4 changes: 2 additions & 2 deletions deploy-agent/tests/unit/deploy/types/test_ping_request.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from deployd.common.types import DeployStage
from deployd.common.types import AgentStatus, DeployStage
from deployd.types.ping_request import PingRequest
from deployd.types.ping_report import PingReport
import unittest
Expand All @@ -10,7 +10,7 @@ def test_to_json_enums(self):
PingReport(
{
"deployStage": DeployStage.POST_RESTART,
"status": 4,
"status": AgentStatus.SCRIPT_FAILED,
}
),
PingReport(
Expand Down

0 comments on commit 72eb2de

Please sign in to comment.