def test_get_by_name_nonexistent(self):
        name = "yodep-{0}".format(str(uuid.uuid4()))
        dep = _utils.create_deployment(name=name)

        if _utils.is_reachable(dep.config):
            result = K8sDeployment.get_by_name(config=dep.config, name=name)
            self.assertIsInstance(result, list)
            self.assertEqual(0, len(result))
    def test_get_by_name(self):
        cont_name = "yocontainer"
        container = _utils.create_container(name=cont_name)
        name = "yodep-{0}".format(str(uuid.uuid4()))
        dep = _utils.create_deployment(name=name)
        dep.add_container(container)

        if _utils.is_reachable(dep.config):
            dep.create()
            result = K8sDeployment.get_by_name(config=dep.config, name=name)
            self.assertIsInstance(result, list)
            self.assertEqual(1, len(result))
            self.assertIsInstance(result[0], K8sDeployment)
            self.assertEqual(dep, result[0])
 def test_get_by_name_invalid_config(self):
     name = "yoname"
     config = object()
     with self.assertRaises(SyntaxError):
         K8sDeployment.get_by_name(config=config, name=name)
 def test_get_by_name_invalid_name(self):
     name = object()
     with self.assertRaises(SyntaxError):
         K8sDeployment.get_by_name(name=name)
 def test_get_by_name_none_args(self):
     with self.assertRaises(SyntaxError):
         K8sDeployment.get_by_name()