@@ -105,6 +105,29 @@ def test_wls_init_nondefault_timeout():
105105 assert wls .timeout == 832
106106
107107
108+ def test_wls_repr ():
109+ collection = {
110+ "version" : "12.2.1.3" ,
111+ "isLatest" : True ,
112+ "lifecycle" : "active" ,
113+ "links" : [
114+ {"rel" : "edit" , "href" : "https://edit-link" },
115+ {"rel" : "domainRuntime" , "href" : "https://domainruntime-link" },
116+ ],
117+ }
118+ with requests_mock .mock () as r :
119+ r .get (
120+ "https://wls.example.com:7001/management/weblogic/latest" , json = collection
121+ )
122+ wls = wls_rest_python .WLS (
123+ "https://wls.example.com:7001" , "weblogic" , "Welcome1"
124+ )
125+ assert (
126+ repr (wls )
127+ == "<WLS url='https://wls.example.com:7001/management/weblogic/latest' username='weblogic' version='12.2.1.3'>"
128+ )
129+
130+
108131def test_wls_get ():
109132 fake_wls = MagicMock (spec = wls_rest_python .WLS )
110133 fake_wls .timeout = 372
@@ -567,6 +590,20 @@ def test_wls_object_without_len():
567590 len (wls_obj )
568591
569592
593+ def test_wls_object_repr ():
594+ collection = {
595+ "links" : [{"rel" : "self" , "href" : "https://self-link" }],
596+ "attr1" : False ,
597+ "attr2" : 9 ,
598+ "attr3" : - 7 ,
599+ "name" : "what" ,
600+ }
601+ fake_wls = MagicMock ()
602+ fake_wls .get = MagicMock (return_value = collection )
603+ wls_obj = wls_rest_python .WLSObject ("name" , "https://url" , fake_wls )
604+ assert repr (wls_obj ) == "<WLSObject name='name' url='https://url'>"
605+
606+
570607def test_wls_object_empty_items ():
571608 # If there is an empty item array in the response,
572609 # it means it is iterable, only withouth objects
@@ -651,3 +688,9 @@ def test_wls_action_async():
651688 action_answer = wls_action (prefer_async = True )
652689 fake_wls .post .assert_called_once_with ("https://url" , True , json = {})
653690 assert isinstance (action_answer , MagicMock )
691+
692+
693+ def test_wls_action_repr ():
694+ fake_wls = MagicMock ()
695+ wls_action = wls_rest_python .WLSAction ("name" , "https://url" , fake_wls )
696+ assert repr (wls_action ) == "<WLSAction name='name' url='https://url'>"
0 commit comments