Skip to content

Commit

Permalink
Update the payload factories to support new attribute operations
Browse files Browse the repository at this point in the history
This change updates the request and response payload factories to
add support for the Set, Modify, and DeleteAttribute payloads.
Unit tests have been added to cover the changes.

Partially implements #547
  • Loading branch information
PeterHamilton committed Dec 13, 2019
1 parent 4e59a8a commit 48350a4
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
5 changes: 5 additions & 0 deletions kmip/core/factories/payloads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def create(self, operation):
return self._create_get_attribute_list_payload()
elif operation is enums.Operation.ADD_ATTRIBUTE:
return self._create_add_attribute_payload()
elif operation is enums.Operation.SET_ATTRIBUTE:
return self._create_set_attribute_payload()
elif operation is enums.Operation.MODIFY_ATTRIBUTE:
return self._create_modify_attribute_payload()
elif operation is enums.Operation.DELETE_ATTRIBUTE:
Expand Down Expand Up @@ -144,6 +146,9 @@ def _create_get_attribute_list_payload(self):
def _create_add_attribute_payload(self):
raise NotImplementedError()

def _create_set_attribute_payload(self):
raise NotImplementedError()

def _create_modify_attribute_payload(self):
raise NotImplementedError()

Expand Down
10 changes: 10 additions & 0 deletions kmip/core/factories/payloads/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

class RequestPayloadFactory(PayloadFactory):

# TODO (peterhamilton) Alphabetize these
def _create_create_payload(self):
return payloads.CreateRequestPayload()

Expand Down Expand Up @@ -52,6 +53,15 @@ def _create_get_attribute_list_payload(self):
def _create_get_attributes_payload(self):
return payloads.GetAttributesRequestPayload()

def _create_delete_attribute_payload(self):
return payloads.DeleteAttributeRequestPayload()

def _create_set_attribute_payload(self):
return payloads.SetAttributeRequestPayload()

def _create_modify_attribute_payload(self):
return payloads.ModifyAttributeRequestPayload()

def _create_destroy_payload(self):
return payloads.DestroyRequestPayload()

Expand Down
10 changes: 10 additions & 0 deletions kmip/core/factories/payloads/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

class ResponsePayloadFactory(PayloadFactory):

# TODO (peterhamilton) Alphabetize these
def _create_create_payload(self):
return payloads.CreateResponsePayload()

Expand Down Expand Up @@ -52,6 +53,15 @@ def _create_get_attribute_list_payload(self):
def _create_get_attributes_payload(self):
return payloads.GetAttributesResponsePayload()

def _create_delete_attribute_payload(self):
return payloads.DeleteAttributeResponsePayload()

def _create_set_attribute_payload(self):
return payloads.SetAttributeResponsePayload()

def _create_modify_attribute_payload(self):
return payloads.ModifyAttributeResponsePayload()

def _create_destroy_payload(self):
return payloads.DestroyResponsePayload()

Expand Down
6 changes: 6 additions & 0 deletions kmip/tests/unit/core/factories/payloads/test_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ def test_create_delete_attribute_payload(self):
enums.Operation.DELETE_ATTRIBUTE
)

def test_create_set_attribute_payload(self):
self._test_not_implemented(
self.factory.create,
enums.Operation.SET_ATTRIBUTE
)

def test_create_obtain_lease_payload(self):
self._test_not_implemented(
self.factory.create,
Expand Down
16 changes: 8 additions & 8 deletions kmip/tests/unit/core/factories/payloads/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ def test_create_add_attribute_payload(self):
)

def test_create_modify_attribute_payload(self):
self._test_not_implemented(
self.factory.create,
enums.Operation.MODIFY_ATTRIBUTE
)
payload = self.factory.create(enums.Operation.MODIFY_ATTRIBUTE)
self.assertIsInstance(payload, payloads.ModifyAttributeRequestPayload)

def test_create_delete_attribute_payload(self):
self._test_not_implemented(
self.factory.create,
enums.Operation.DELETE_ATTRIBUTE
)
payload = self.factory.create(enums.Operation.DELETE_ATTRIBUTE)
self.assertIsInstance(payload, payloads.DeleteAttributeRequestPayload)

def test_create_set_attribute_payload(self):
payload = self.factory.create(enums.Operation.SET_ATTRIBUTE)
self.assertIsInstance(payload, payloads.SetAttributeRequestPayload)

def test_create_obtain_lease_payload(self):
self._test_not_implemented(
Expand Down
16 changes: 8 additions & 8 deletions kmip/tests/unit/core/factories/payloads/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ def test_create_add_attribute_payload(self):
)

def test_create_modify_attribute_payload(self):
self._test_not_implemented(
self.factory.create,
enums.Operation.MODIFY_ATTRIBUTE
)
payload = self.factory.create(enums.Operation.MODIFY_ATTRIBUTE)
self.assertIsInstance(payload, payloads.ModifyAttributeResponsePayload)

def test_create_delete_attribute_payload(self):
self._test_not_implemented(
self.factory.create,
enums.Operation.DELETE_ATTRIBUTE
)
payload = self.factory.create(enums.Operation.DELETE_ATTRIBUTE)
self.assertIsInstance(payload, payloads.DeleteAttributeResponsePayload)

def test_create_set_attribute_payload(self):
payload = self.factory.create(enums.Operation.SET_ATTRIBUTE)
self.assertIsInstance(payload, payloads.SetAttributeResponsePayload)

def test_create_obtain_lease_payload(self):
self._test_not_implemented(
Expand Down

0 comments on commit 48350a4

Please sign in to comment.