summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Bartra <rb560u@att.com>2018-10-21 21:24:41 -0400
committerRick Bartra <rb560u@att.com>2018-10-30 09:59:38 -0400
commit88fe773cd7615ded05657329f39d2fd79af6ad7e (patch)
treed17f86bd2db81f800176cc9f685e1d9be9d6b40e
parent464d2c0ea5ebb50bee615a0e0f2624c3aa40d9bd (diff)
Fix document is_control method
The document.py `is_control` method incorrectly checks if a document is a Control document. Per the documentation [0], Control documents have `metadata.schema` of `metadata/Control/v1`. This commit updates the `is_control` method to correctly check for Control documents. [0] https://github.com/openstack/airship-deckhand/blob/1d4cc81dfaa9a5280625074e569fa4ab9dc7fd09/doc/source/users/document-types.rst#control-documents Change-Id: I60ca8f31a61987b4e756784fce0f5a751639ae9e
Notes
Notes (review): Code-Review+2: Felipe Monteiro <felipe.monteiro@att.com> Code-Review+2: Aaron Sheffield <ajs@sheffieldfamily.net> Workflow+1: Aaron Sheffield <ajs@sheffieldfamily.net> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 30 Oct 2018 17:33:19 +0000 Reviewed-on: https://review.openstack.org/613688 Project: openstack/airship-deckhand Branch: refs/heads/master
-rw-r--r--deckhand/common/document.py2
-rw-r--r--deckhand/tests/unit/engine/test_document_layering_negative.py24
2 files changed, 7 insertions, 19 deletions
diff --git a/deckhand/common/document.py b/deckhand/common/document.py
index 739cfc3..04877c5 100644
--- a/deckhand/common/document.py
+++ b/deckhand/common/document.py
@@ -75,7 +75,7 @@ class DocumentDict(dict):
75 75
76 @property 76 @property
77 def is_control(self): 77 def is_control(self):
78 return self.schema.startswith('deckhand/Control') 78 return self.metadata.get('schema', '').startswith('metadata/Control')
79 79
80 @property 80 @property
81 def layering_definition(self): 81 def layering_definition(self):
diff --git a/deckhand/tests/unit/engine/test_document_layering_negative.py b/deckhand/tests/unit/engine/test_document_layering_negative.py
index 1ca1bc3..85a7f42 100644
--- a/deckhand/tests/unit/engine/test_document_layering_negative.py
+++ b/deckhand/tests/unit/engine/test_document_layering_negative.py
@@ -221,31 +221,19 @@ class TestDocumentLayeringNegative(
221 self.assertRaises( 221 self.assertRaises(
222 errors.InvalidDocumentParent, self._test_layering, documents) 222 errors.InvalidDocumentParent, self._test_layering, documents)
223 223
224 def test_layering_invalid_layer_order_raises_exc(self): 224 def test_layering_empty_layer_order_raises_exc(self):
225 """Validate that an invalid layerOrder (which means that the document 225 """Validate that an empty layerOrder (which means that the document
226 layer won't be found in the layerOrder) raises an exception. 226 layer won't be found in the layerOrder) raises an exception.
227 """ 227 """
228 doc_factory = factories.DocumentFactory(1, [1]) 228 doc_factory = factories.DocumentFactory(1, [1])
229 lp_template, document = doc_factory.gen_test({ 229 layering_policy, document = doc_factory.gen_test(
230 "_GLOBAL_SUBSTITUTIONS_1_": [{ 230 {}, global_abstract=False)
231 "dest": {
232 "path": ".c"
233 },
234 "src": {
235 "schema": "deckhand/Certificate/v1",
236 "name": "global-cert",
237 "path": "."
238 }
239
240 }],
241 }, global_abstract=False)
242 231
243 layering_policy = copy.deepcopy(lp_template) 232 layering_policy['data']['layerOrder'] = []
244 del layering_policy['data']['layerOrder']
245 error_re = "layer \'global\' .* was not found in layerOrder.*" 233 error_re = "layer \'global\' .* was not found in layerOrder.*"
246 self.assertRaisesRegexp( 234 self.assertRaisesRegexp(
247 errors.InvalidDocumentLayer, error_re, self._test_layering, 235 errors.InvalidDocumentLayer, error_re, self._test_layering,
248 [layering_policy, document], validate=True) 236 [layering_policy, document])
249 237
250 238
251class TestDocumentLayeringValidationNegative( 239class TestDocumentLayeringValidationNegative(