File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 ()
Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments