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_init_no_args(self): try: K8sDeployment() self.fail("Should not fail.") except SyntaxError: pass except IOError: pass except Exception as err: self.fail("Unhandled exception: [ {0} ]".format( err.__class__.__name__))
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 create_deployment(config=None, name=None): if config is None: config = create_config() obj = K8sDeployment(config=config, name=name) return obj
def test_init_with_invalid_config(self): config = object() with self.assertRaises(SyntaxError): K8sDeployment(config=config)
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_invalid_config(self): name = "yoname" config = object() with self.assertRaises(SyntaxError): K8sDeployment.get_by_name(config=config, name=name)
def test_get_by_name_none_args(self): with self.assertRaises(SyntaxError): K8sDeployment.get_by_name()