def test_resource_custom_label(self): resource = Resource( APP, NODE, {"metadata": {"labels": {"custom-label": "custom"}}} ) compare = DEFAULT_RESOURCE["metadata"]["labels"].keys() self.assertGreaterEqual(resource.labels.keys(), compare) self.assertEqual(resource.labels["custom-label"], "custom")
def test_validate_apiversion(self): resource = Resource(APP, NODE, {"kind": "BadKindName"}) with self.assertRaises(ValueError): resource._validate()
def test_validate_kind(self): resource = Resource(APP, NODE, {"kind": ""}) with self.assertRaises(ValueError): resource._validate()
def test_resource_custom_namespace(self): resource = Resource(APP, NODE, {"metadata": {"namespace": "custom"}}) self.assertEqual(resource.manifest["metadata"]["namespace"], "custom") self.assertEqual(resource.namespace, "custom")
def test_resource_custom_kind(self): resource = Resource(APP, NODE, {"kind": "StatefulSet"}) self.assertEqual(resource.manifest["kind"], "StatefulSet")
def test_resource_custom_name(self): resource = Resource(APP, NODE, {"metadata": {"name": "custom"}}) self.assertEqual(resource.labels["app.kubernetes.io/name"], "custom") self.assertEqual(resource.manifest["metadata"]["name"], "custom") self.assertEqual(resource.name, "custom")
def test_resource_metadata_keys(self): resource = Resource(APP, NODE, {}) compare = DEFAULT_RESOURCE["metadata"].keys() self.assertEqual(compare, resource.manifest["metadata"].keys())
def test_resource_label_keys(self): resource = Resource(APP, NODE, {}) compare = DEFAULT_RESOURCE["metadata"]["labels"].keys() self.assertEqual(compare, resource.labels.keys())
def test_resource_keys(self): resource = Resource(APP, NODE, {}) compare = DEFAULT_RESOURCE.keys() self.assertEqual(compare, resource.manifest.keys())