@@ -159,6 +159,20 @@ def test_eq_host(self):
159159 self .assertEqual (h1 , h4 )
160160 self .assertNotEqual (h2 , h3 )
161161
162+ def test_host_api (self ):
163+ h = NmapParser .parse (host2 )
164+ self .assertEqual (h .starttime , "1361738318" )
165+ self .assertEqual (h .endtime , "13617386177" )
166+ self .assertEqual (h .address , '127.0.0.1' )
167+ self .assertEqual (h .status , "up" )
168+ self .assertEqual (h .hostnames , ['localhost' , 'localhost' , 'localhost2' ])
169+
170+ h2 = NmapParser .parse (host3 )
171+ self .assertEqual (len (h2 .services ), 5 )
172+ self .assertEqual (len (h2 .get_ports ()), 5 )
173+ self .assertEqual (len (h2 .get_open_ports ()), 3 )
174+ self .assertEqual (h2 .get_service (22 , "tcp" ).state , "open" )
175+
162176 def test_diff_host (self ):
163177 h1 = NmapParser .parse (host1 )
164178 h2 = NmapParser .parse (host2 )
@@ -201,6 +215,6 @@ def test_diff_host(self):
201215
202216
203217if __name__ == '__main__' :
204- test_suite = ['test_eq_host' , 'test_diff_host' ]
218+ test_suite = ['test_eq_host' , 'test_host_api' , ' test_diff_host' ]
205219 suite = unittest .TestSuite (map (TestNmapHost , test_suite ))
206220 test_result = unittest .TextTestRunner (verbosity = 2 ).run (suite )
0 commit comments