Skip to content

Commit e61d188

Browse files
committed
MSA-11489 - Add method delete MS method
1 parent 93ad5f4 commit e61d188

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

msa_sdk/configuration_object.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""Module Configuration Object."""
2+
3+
from msa_sdk.msa_api import MSA_API
4+
5+
6+
class ConfigurationObject(MSA_API):
7+
"""Class Configuration Ojbect."""
8+
9+
def __init__(self):
10+
"""
11+
Initialize.
12+
13+
Parameters
14+
----------
15+
None
16+
17+
Returns
18+
-------
19+
None
20+
21+
"""
22+
MSA_API.__init__(self)
23+
self.api_path = "/configuration-objects"
24+
25+
def delete(self, device_id: int, object_name: str = "") -> None:
26+
"""
27+
Delete microservice object instance.
28+
29+
Parameters
30+
----------
31+
device_id: Integer
32+
Device id
33+
34+
object_name: String
35+
Object name
36+
37+
Returns
38+
-------
39+
None
40+
"""
41+
if object_name:
42+
self.path = "{}/{}/{}".format(self.api_path, device_id,
43+
object_name)
44+
else:
45+
self.path = "{}/{}".format(self.api_path, device_id)
46+
47+
self._call_delete()

tests/test_configuration_object.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
Test Repository
3+
"""
4+
from unittest.mock import patch
5+
6+
from msa_sdk.configuration_object import ConfigurationObject
7+
8+
9+
def test_delete_device():
10+
"""
11+
Test Delete device
12+
"""
13+
14+
with patch('msa_sdk.msa_api.MSA_API._call_delete') as mock_call_delete:
15+
conf_object = ConfigurationObject()
16+
17+
conf_object.delete(200)
18+
19+
assert conf_object.path == "/configuration-objects/200"
20+
mock_call_delete.assert_called_once_with()
21+
22+
23+
def test_delete_device_object():
24+
"""
25+
Tetst Delete Device Object
26+
"""
27+
28+
with patch('msa_sdk.msa_api.MSA_API._call_delete') as mock_call_delete:
29+
conf_object = ConfigurationObject()
30+
31+
conf_object.delete(200, 'ObjectName')
32+
33+
assert conf_object.path == "/configuration-objects/200/ObjectName"
34+
mock_call_delete.assert_called_once_with()

0 commit comments

Comments
 (0)