@@ -49,6 +49,9 @@ def setUp(self):
4949 self ._proxy_user = 'admin'
5050 self ._proxy_pass = 'password'
5151
52+ self ._hosts_ipaddr = '192.168.0.1'
53+ self ._hosts_hostname = 'address.ctera.com'
54+
5255 def test_network_status (self ):
5356 get_response = 'Success'
5457 self ._init_filer (get_response = get_response )
@@ -351,3 +354,27 @@ def _create_proxy_param(enabled=None, address=None, port=None, username=None, pa
351354 if password :
352355 m .password = password
353356 return m
357+
358+ def test_get_hosts_file (self ):
359+ get_response = 'Success'
360+ self ._init_filer (get_response = get_response )
361+ ret = network .Network (self ._filer ).hosts .get ()
362+ self ._filer .api .get .assert_called_once_with ('/config/network/hostsFileEntries' )
363+ self .assertEqual (ret , get_response )
364+
365+ def test_add_hosts_file_entry (self ):
366+ add_response = 'Success'
367+ self ._init_filer (add_response = add_response )
368+ ret = network .Network (self ._filer ).hosts .add (self ._hosts_ipaddr , self ._hosts_hostname )
369+ self ._filer .api .add .assert_called_once_with ('/config/network/hostsFileEntries' , mock .ANY )
370+ actual_param = self ._filer .api .add .call_args [0 ][1 ]
371+ expected_param = munch .Munch (dict (ip = self ._hosts_ipaddr , hostName = self ._hosts_hostname ))
372+ self ._assert_equal_objects (actual_param , expected_param )
373+ self .assertEqual (ret , add_response )
374+
375+ def test_delete_hosts_file_entry (self ):
376+ delete_response = 'Success'
377+ self ._init_filer (delete_response = delete_response )
378+ ret = network .Network (self ._filer ).hosts .delete (self ._hosts_hostname )
379+ self ._filer .api .delete .assert_called_once_with (f'/config/network/hostsFileEntries/{ self ._hosts_hostname } ' )
380+ self .assertEqual (ret , delete_response )
0 commit comments