コード例 #1
0
    def test_get_by_name_nonexistent(self):
        name = "yopod-{0}".format(str(uuid.uuid4()))
        config = K8sConfig(kubeconfig=_utils.kubeconfig_fallback)

        if _utils.is_reachable(config):
            pods = K8sPod.get_by_name(config=config, name=name)
            self.assertIsInstance(pods, list)
            self.assertEqual(0, len(pods))
コード例 #2
0
    def test_get_by_name(self):
        name = "yocontainer"
        container = _utils.create_container(name=name)
        name = "yopod-{0}".format(str(uuid.uuid4()))
        pod = _utils.create_pod(name=name)
        pod.add_container(container)

        if _utils.is_reachable(pod.config):
            pod.create()
            pods = K8sPod.get_by_name(config=pod.config, name=name)
            self.assertIsInstance(pods, list)
            self.assertEqual(1, len(pods))
コード例 #3
0
    def test_update_name_fails(self):
        name = "yocontainer"
        container = _utils.create_container(name=name)
        name1 = "yopod1"
        name2 = "yopod2"
        pod = _utils.create_pod(name=name1)
        pod.add_container(container)

        if _utils.is_reachable(pod.config):
            pod.create()
            result = K8sPod.get_by_name(config=pod.config, name=name1)
            self.assertIsInstance(result, list)
            self.assertEqual(1, len(result))
            self.assertIsInstance(result[0], K8sPod)
            result[0].name = name2
            with self.assertRaises(NotFoundException):
                result[0].update()
コード例 #4
0
    def test_update_namespace_fails(self):
        name = "yocontainer"
        container = _utils.create_container(name=name)
        name = "yopod-{0}".format(str(uuid.uuid4()))
        nspace = "yonamespace"
        pod1 = _utils.create_pod(name=name)
        pod1.add_container(container)

        if _utils.is_reachable(pod1.config):
            pod1.create()
            result = K8sPod.get_by_name(config=pod1.config, name=name)
            self.assertIsInstance(result, list)
            self.assertEqual(1, len(result))
            pod2 = result[0]
            self.assertIsInstance(pod2, K8sPod)
            self.assertNotEqual(pod2.namespace, nspace)
            self.assertEqual(pod1, pod2)
            pod2.namespace = nspace
            with self.assertRaises(BadRequestException):
                pod2.update()
コード例 #5
0
 def test_get_by_name_invalid_args(self):
     name = object()
     config = _utils.create_config()
     with self.assertRaises(SyntaxError):
         K8sPod.get_by_name(config=config, name=name)
コード例 #6
0
 def test_get_by_name_none_args(self):
     config = _utils.create_config()
     with self.assertRaises(SyntaxError):
         K8sPod.get_by_name(config=config)