Skip to content

Commit

Permalink
[#543] fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Blatov committed Nov 19, 2018
1 parent 44df846 commit 0ae0045
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions legion/tests/test_edi.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ def test_edi_undeploy_model_by_id(self):
self.assertEqual(deployments[0].image,
'127.0.0.1/legion/test-bare-model-api-model-1:0.9.0-20181106123540.560.3b9739a')


def test_negative_edi_undeploy_by_invalid_model_id(self):
with EDITestServer() as edi:
with m_func('kubernetes.client.CoreV1Api.list_namespaced_service', 'one_model'), \
Expand All @@ -275,14 +274,14 @@ def test_negative_edi_undeploy_by_invalid_model_id(self):
self.assertEqual(str(e),
"Got error from server: 'No one model can be found'")


def test_edi_scale_up(self):
with EDITestServer() as edi:
with m_func('kubernetes.client.CoreV1Api.list_namespaced_service', 'one_model'), \
m_func('kubernetes.client.ExtensionsV1beta1Api.list_namespaced_deployment', 'one_model'), \
m_func('kubernetes.client.ExtensionsV1beta1Api.patch_namespaced_deployment',
'one_model_scaled_to_2'), \
m_func('kubernetes.client.ExtensionsV1beta1Api.list_namespaced_deployment', 'one_model_scaled_to_2'), \
m_func('kubernetes.client.ExtensionsV1beta1Api.list_namespaced_deployment',
'one_model_scaled_to_2'), \
mock.patch('legion.k8s.utils.build_client', return_value=None):
deployments = edi.edi_client.scale('demo-abc-model', 2)
self.assertIsInstance(deployments, list)
Expand All @@ -297,11 +296,11 @@ def test_edi_scale_up(self):
self.assertEqual(deployments[0].image,
'127.0.0.1/legion/test-bare-model-api-model-1:0.9.0-20181106123540.560.3b9739a')


def test_edi_scale_down(self):
with EDITestServer() as edi:
with m_func('kubernetes.client.CoreV1Api.list_namespaced_service', 'one_model'), \
m_func('kubernetes.client.ExtensionsV1beta1Api.list_namespaced_deployment', 'one_model_scaled_to_2'), \
m_func('kubernetes.client.ExtensionsV1beta1Api.list_namespaced_deployment',
'one_model_scaled_to_2'), \
m_func('kubernetes.client.ExtensionsV1beta1Api.patch_namespaced_deployment',
'one_model_scaled_to_1'), \
m_func('kubernetes.client.ExtensionsV1beta1Api.list_namespaced_deployment', 'one_model'), \
Expand All @@ -319,20 +318,19 @@ def test_edi_scale_down(self):
self.assertEqual(deployments[0].image,
'127.0.0.1/legion/test-bare-model-api-model-1:0.9.0-20181106123540.560.3b9739a')


def test_negative_edi_scale_to_0(self):
with EDITestServer() as edi:
with m_func('kubernetes.client.CoreV1Api.list_namespaced_service', 'one_model'), \
m_func('kubernetes.client.ExtensionsV1beta1Api.list_namespaced_deployment', 'one_model'), \
m_func('kubernetes.client.ExtensionsV1beta1Api.patch_namespaced_deployment', 'one_model_scaled_to_2'), \
m_func('kubernetes.client.ExtensionsV1beta1Api.patch_namespaced_deployment',
'one_model_scaled_to_2'), \
mock.patch('legion.k8s.utils.build_client', return_value=None):
try:
edi.edi_client.scale('demo-abc-model', 0)
except Exception as e:
self.assertEqual(str(e),
"Got error from server: 'Invalid scale parameter: should be greater then 0'")


def test_negative_edi_invalid_model_id(self):
with EDITestServer() as edi:
with m_func('kubernetes.client.CoreV1Api.list_namespaced_service', 'one_model'), \
Expand All @@ -347,7 +345,6 @@ def test_negative_edi_invalid_model_id(self):
self.assertEqual(str(e),
"Got error from server: 'No one model can be found'")


def test_edi_inspect_all_models_by_version(self):
with EDITestServer() as edi:
with m_func('kubernetes.client.CoreV1Api.list_namespaced_service', 'two_models_1_id_and_2_versions'), \
Expand Down Expand Up @@ -377,7 +374,6 @@ def test_edi_inspect_all_models_by_version(self):
self.assertEqual(deployments[1].image,
'127.0.0.1/legion/test-bare-model-api-model-2:0.9.0-20181106123540.560.3b9739a')


def test_edi_inspect_all_models_by_id(self):
with EDITestServer() as edi:
with m_func('kubernetes.client.CoreV1Api.list_namespaced_service', 'two_models_1_id_and_2_versions'), \
Expand Down Expand Up @@ -407,7 +403,6 @@ def test_edi_inspect_all_models_by_id(self):
self.assertEqual(deployments[1].image,
'127.0.0.1/legion/test-bare-model-api-model-2:0.9.0-20181106123540.560.3b9739a')


def test_negative_edi_scale_without_version(self):
with EDITestServer() as edi:
with m_func('kubernetes.client.CoreV1Api.list_namespaced_service', 'two_models_1_id_and_2_versions'), \
Expand All @@ -421,7 +416,6 @@ def test_negative_edi_scale_without_version(self):
self.assertEqual(str(e),
"Got error from server: 'Please specify version of model'")


def test_negative_edi_undeploy_without_version(self):
with EDITestServer() as edi:
with m_func('kubernetes.client.CoreV1Api.list_namespaced_service', 'two_models_1_id_and_2_versions'), \
Expand All @@ -436,7 +430,6 @@ def test_negative_edi_undeploy_without_version(self):
self.assertEqual(str(e),
"Got error from server: 'Please specify version of model'")


def test_edi_undeploy_all_models_by_version(self):
with EDITestServer() as edi:
with m_func('kubernetes.client.CoreV1Api.list_namespaced_service', 'two_models_1_id_and_2_versions'), \
Expand Down Expand Up @@ -469,7 +462,6 @@ def test_edi_undeploy_all_models_by_version(self):
self.assertEqual(deployments[1].image,
'127.0.0.1/legion/test-bare-model-api-model-2:0.9.0-20181106123540.560.3b9739a')


def test_edi_scale_all_models_by_version(self):
with EDITestServer() as edi:
with m_func('kubernetes.client.CoreV1Api.list_namespaced_service', 'two_models_1_id_and_2_versions'), \
Expand Down Expand Up @@ -503,7 +495,6 @@ def test_edi_scale_all_models_by_version(self):
self.assertEqual(deployments[1].image,
'127.0.0.1/legion/test-bare-model-api-model-2:0.9.0-20181106123540.560.3b9739a')


# TODO uncomment after https://github.com/legion-platform/legion/pull/553 will be merged
# def test_edi_scale_all_models_by_id(self):
# with mock.patch('legion.k8s.enclave.Enclave.graphite_service', return_value=None):
Expand Down

0 comments on commit 0ae0045

Please sign in to comment.