<s> import unittest <EOL> from suds import WebFault <EOL> from onvif import ONVIFCamera , ONVIFError <EOL> CAM_HOST = '<STR_LIT>' <EOL> CAM_PORT = <NUM_LIT> <EOL> CAM_USER = '<STR_LIT>' <EOL> CAM_PASS = '<STR_LIT>' <EOL> DEBUG = False <EOL> def log ( ret ) : <EOL> if DEBUG : <EOL> print ret <EOL> class TestDevice ( unittest . TestCase ) : <EOL> cam = ONVIFCamera ( CAM_HOST , CAM_PORT , CAM_USER , CAM_PASS ) <EOL> def test_GetWsdlUrl ( self ) : <EOL> ret = self . cam . devicemgmt . GetWsdlUrl ( ) <EOL> def test_GetServices ( self ) : <EOL> '''<STR_LIT>''' <EOL> params = { '<STR_LIT>' : True } <EOL> ret = self . cam . devicemgmt . GetServices ( params ) <EOL> params = self . cam . devicemgmt . create_type ( '<STR_LIT>' ) <EOL> params . IncludeCapability = False <EOL> ret = self . cam . devicemgmt . GetServices ( params ) <EOL> def test_GetServiceCapabilities ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = self . cam . devicemgmt . GetServiceCapabilities ( ) <EOL> ret . Network . _IPFilter <EOL> def test_GetCapabilities ( self ) : <EOL> '''<STR_LIT>''' <EOL> categorys = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> ret = self . cam . devicemgmt . GetCapabilities ( ) <EOL> for category in categorys : <EOL> ret = self . cam . devicemgmt . GetCapabilities ( { '<STR_LIT>' : category } ) <EOL> with self . assertRaises ( ONVIFError ) : <EOL> self . cam . devicemgmt . GetCapabilities ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_GetHostname ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . cam . devicemgmt . GetHostname ( ) <EOL> def test_SetHostname ( self ) : <EOL> '''<STR_LIT>''' <EOL> pre_host_name = self . cam . devicemgmt . GetHostname ( ) <EOL> self . cam . devicemgmt . SetHostname ( { '<STR_LIT:Name>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( self . cam . devicemgmt . GetHostname ( ) . Name , '<STR_LIT>' ) <EOL> self . cam . devicemgmt . SetHostname ( pre_host_name ) <EOL> def test_SetHostnameFromDHCP ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = self . cam . devicemgmt . SetHostnameFromDHCP ( dict ( FromDHCP = False ) ) <EOL> self . assertTrue ( isinstance ( ret , bool ) ) <EOL> def test_GetDNS ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = self . cam . devicemgmt . GetDNS ( ) <EOL> self . assertTrue ( hasattr ( ret , '<STR_LIT>' ) ) <EOL> if ret . FromDHCP == False : <EOL> log ( ret . DNSManual [ <NUM_LIT:0> ] . Type ) <EOL> log ( ret . DNSManual [ <NUM_LIT:0> ] . IPv4Address ) <EOL> def test_SetDNS ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = self . cam . devicemgmt . SetDNS ( dict ( FromDHCP = False ) ) <EOL> def test_GetNTP ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = self . cam . devicemgmt . GetNTP ( ) <EOL> if ret . FromDHCP == False : <EOL> self . assertTrue ( hasattr ( ret , '<STR_LIT>' ) ) <EOL> log ( ret . NTPManual ) <EOL> def test_SetNTP ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = self . cam . devicemgmt . SetNTP ( dict ( FromDHCP = False ) ) <EOL> def test_GetDynamicDNS ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = self . cam . devicemgmt . GetDynamicDNS ( ) <EOL> log ( ret ) <EOL> def test_SetDynamicDNS ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = self . cam . devicemgmt . GetDynamicDNS ( ) <EOL> ret = self . cam . devicemgmt . SetDynamicDNS ( dict ( Type = ret . Type , Name = "<STR_LIT>" ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
