-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'iroquebert/enum-over-two-dicts' of github.com:pinterest…
…/teletraan into iroquebert/enum-over-two-dicts
- Loading branch information
Showing
22 changed files
with
227 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import mock | ||
import unittest | ||
from tests import TestCase | ||
|
||
from deployd.client.client import Client | ||
from deployd.client.base_client import BaseClient | ||
from deployd.common.config import Config | ||
|
||
|
||
class TestClient(TestCase): | ||
def test_extends_base_client(self): | ||
self.assertTrue(issubclass(Client, BaseClient)) | ||
|
||
def test_no_config_provided(self): | ||
with self.assertRaises(AttributeError): | ||
Client() | ||
|
||
def test_read_host_info(self): | ||
client = Client(config=Config()) | ||
client._ec2_tags = {} | ||
client._availability_zone = "us-east-1" | ||
return_value: bool = client._read_host_info() | ||
self.assertIsNotNone(client._hostname) | ||
self.assertIsNotNone(client._ip) | ||
self.assertTrue(return_value) | ||
|
||
def test_read_host_info_no_ec2_tags_provided(self): | ||
client = Client(config=Config()) | ||
with self.assertRaises(AttributeError): | ||
client._read_host_info() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from deployd.types.ping_report import PingReport | ||
import unittest | ||
|
||
|
||
class TestPingReport(unittest.TestCase): | ||
def test_init_enums(self): | ||
report = PingReport(jsonValue={ | ||
"deployStage": 0, | ||
"status": 0, | ||
}) | ||
self.assertEqual(report.deployStage, "UNKNOWN") | ||
self.assertEqual(report.status, "SUCCEEDED") | ||
|
||
report = PingReport(jsonValue={ | ||
"deployStage": 10, | ||
"status": 7, | ||
}) | ||
self.assertEqual(report.deployStage, "STOPPED") | ||
self.assertEqual(report.status, "TOO_MANY_RETRY") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from deployd.types.ping_request import PingRequest | ||
from deployd.types.ping_report import PingReport | ||
import unittest | ||
|
||
|
||
class TestPingRequest(unittest.TestCase): | ||
def test_to_json_enums(self): | ||
reports = [ | ||
PingReport({ | ||
"deployStage": 7, | ||
"status": 4, | ||
}), | ||
PingReport({ | ||
"deployStage": "POST_RESTART", | ||
"status": "SCRIPT_FAILED", | ||
}), | ||
] | ||
request = PingRequest(reports=reports) | ||
json_request = request.to_json() | ||
self.assertEqual(json_request["reports"][0]["deployStage"], "POST_RESTART") | ||
self.assertEqual(json_request["reports"][0]["agentStatus"], "SCRIPT_FAILED") | ||
self.assertEqual(json_request["reports"][1]["deployStage"], "POST_RESTART") | ||
self.assertEqual(json_request["reports"][1]["agentStatus"], "SCRIPT_FAILED") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.