本文整理汇总了Python中tests._utils.create_service函数的典型用法代码示例。如果您正苦于以下问题:Python create_service函数的具体用法?Python create_service怎么用?Python create_service使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_service函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_nonexistent
def test_delete_nonexistent(self):
name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))
svc = _utils.create_service(name=name)
svc.add_port(name="redis", port=5432, target_port=5432, protocol="tcp")
if _utils.is_reachable(svc.config):
with self.assertRaises(NotFoundException):
svc.delete()
示例2: test_get_label
def test_get_label(self):
name = "yoservice"
svc = _utils.create_service(name=name)
k = "yokey"
v = "yovalue"
svc.add_label(k, v)
self.assertEqual(v, svc.get_label(k))
示例3: test_add_label_invalid_args
def test_add_label_invalid_args(self):
name = "yoservice"
svc = _utils.create_service(name=name)
k = object()
v = object()
with self.assertRaises(SyntaxError):
svc.add_label(k, v)
示例4: test_get_annotation
def test_get_annotation(self):
name = "yoservice"
svc = _utils.create_service(name=name)
k = "yokey"
v_in = "yovalue"
svc.add_annotation(k, v_in)
v_out = svc.get_annotation(k)
self.assertEqual(v_in, v_out)
示例5: test_get_by_name_nonexistent
def test_get_by_name_nonexistent(self):
name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))
svc = _utils.create_service(name=name)
svc.add_port(name="redis", port=5432, target_port=5432, protocol="tcp")
if _utils.is_reachable(svc.config):
_list = K8sService.get_by_name(config=svc.config, name=name)
self.assertIsInstance(_list, list)
self.assertEqual(0, len(_list))
示例6: test_add_annotation_none_args
def test_add_annotation_none_args(self):
name = "yoservice"
svc = _utils.create_service(name=name)
try:
svc.add_annotation()
self.fail("Should not fail.")
except Exception as err:
self.assertIsInstance(err, SyntaxError)
示例7: test_add_annotation
def test_add_annotation(self):
name = "yoservice"
svc = _utils.create_service(name=name)
k = "yokey"
v = "yovalue"
svc.add_annotation(k, v)
self.assertIn(k, svc.annotations)
self.assertEqual(v, svc.annotations[k])
示例8: test_update_nothing_changed
def test_update_nothing_changed(self):
name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))
svc = _utils.create_service(name=name)
svc.add_port(name="redis", port=5432, target_port=5432, protocol="tcp")
if _utils.is_reachable(svc.config):
from_create = svc.create()
from_update = svc.update()
self.assertEqual(from_create, from_update)
示例9: test_struct_service
def test_struct_service(self):
name = "yoname"
svc = _utils.create_service(name=name)
self.assertIsInstance(svc, K8sService)
self.assertIsInstance(svc.model, Service)
self.assertIsInstance(svc.model.metadata, ObjectMeta)
self.assertIsInstance(svc.model.spec, ServiceSpec)
self.assertIsInstance(svc.model.status, ServiceStatus)
示例10: test_init_with_name
def test_init_with_name(self):
name = "yoname"
svc = _utils.create_service(name=name)
self.assertIsNotNone(svc)
self.assertIsInstance(svc, K8sService)
self.assertEqual('Service', svc.obj_type)
self.assertEqual(svc.name, name)
self.assertIsInstance(svc.config, K8sConfig)
示例11: test_create_already_exists
def test_create_already_exists(self):
name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))
svc = _utils.create_service(name=name)
svc.add_port(name="redis", port=5432, target_port=5432, protocol="tcp")
if _utils.is_reachable(svc.config):
svc.create()
with self.assertRaises(UnprocessableEntityException):
svc.create()
示例12: test_create
def test_create(self):
name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))
svc = _utils.create_service(name=name)
svc.add_port(name="redis", port=5432, target_port=5432, protocol="tcp")
if _utils.is_reachable(svc.config):
svc.create()
from_get = svc.get()
self.assertEqual(svc, from_get)
示例13: test_update_set_cluster_ip_fails
def test_update_set_cluster_ip_fails(self):
name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))
svc = _utils.create_service(name=name)
svc.add_port(name="redis", port=5432, target_port=5432, protocol="tcp")
if _utils.is_reachable(svc.config):
svc.create()
svc.cluster_ip = "192.168.123.123"
with self.assertRaises(UnprocessableEntityException):
svc.update()
示例14: test_struct_k8s_service
def test_struct_k8s_service(self):
name = "yoname"
svc = _utils.create_service(name=name)
self.assertIsInstance(svc, K8sService)
self.assertIsInstance(svc.base_url, str)
self.assertIsInstance(svc.config, K8sConfig)
self.assertIsInstance(svc.model, Service)
self.assertIsInstance(svc.name, str)
self.assertIsInstance(svc.obj_type, str)
示例15: test_set_cluster_ip_invalid_ip_address
def test_set_cluster_ip_invalid_ip_address(self):
name = "yoservice"
svc = _utils.create_service(name=name)
svc.add_port('http', 80, 80, 'TCP')
if _utils.is_reachable(svc.config):
svc.create()
ip = "192.168.00000.1234345"
svc.cluster_ip = ip
with self.assertRaises(UnprocessableEntityException):
svc.update()