hydrus/test.py

105 lines
3.1 KiB
Python
Raw Normal View History

2013-07-10 20:25:57 +00:00
from include import HydrusConstants as HC
2013-07-24 20:26:00 +00:00
from include import HydrusTags
2013-08-07 22:25:18 +00:00
from include import TestClientConstants
2013-07-31 21:26:38 +00:00
from include import TestClientDaemons
2013-07-10 20:25:57 +00:00
from include import TestConstants
2013-07-24 20:26:00 +00:00
from include import TestDialogs
2013-07-10 20:25:57 +00:00
from include import TestDB
from include import TestFunctions
2013-07-31 21:26:38 +00:00
from include import TestHydrusDownloading
2013-07-17 20:56:13 +00:00
from include import TestHydrusTags
2013-07-31 21:26:38 +00:00
import collections
2013-07-24 20:26:00 +00:00
import os
2013-07-10 20:25:57 +00:00
import unittest
2013-07-24 20:26:00 +00:00
import wx
2013-07-10 20:25:57 +00:00
2013-07-24 20:26:00 +00:00
class App( wx.App ):
def OnInit( self ):
HC.app = self
self._reads = {}
self._reads[ 'options' ] = {}
self._reads[ 'tag_parents' ] = {}
self._reads[ 'tag_service_precedence' ] = []
self._reads[ 'tag_siblings' ] = {}
2013-07-31 21:26:38 +00:00
self._writes = collections.defaultdict( list )
2013-07-24 20:26:00 +00:00
self._tag_parents_manager = HydrusTags.TagParentsManager()
self._tag_siblings_manager = HydrusTags.TagSiblingsManager()
2013-09-04 16:48:44 +00:00
self._cookies = {}
2013-07-24 20:26:00 +00:00
suites = []
2013-08-07 22:25:18 +00:00
suites.append( unittest.TestLoader().loadTestsFromModule( TestClientConstants ) )
2013-07-31 21:26:38 +00:00
suites.append( unittest.TestLoader().loadTestsFromModule( TestClientDaemons ) )
2013-07-24 20:26:00 +00:00
suites.append( unittest.TestLoader().loadTestsFromModule( TestDialogs ) )
suites.append( unittest.TestLoader().loadTestsFromModule( TestDB ) )
suites.append( unittest.TestLoader().loadTestsFromModule( TestFunctions ) )
2013-07-31 21:26:38 +00:00
suites.append( unittest.TestLoader().loadTestsFromModule( TestHydrusDownloading ) )
2013-07-24 20:26:00 +00:00
suites.append( unittest.TestLoader().loadTestsFromModule( TestHydrusTags ) )
suite = unittest.TestSuite( suites )
runner = unittest.TextTestRunner( verbosity = 1 )
runner.run( suite )
return True
2013-07-10 20:25:57 +00:00
2013-07-24 20:26:00 +00:00
def GetTagParentsManager( self ): return self._tag_parents_manager
def GetTagSiblingsManager( self ): return self._tag_siblings_manager
2013-07-10 20:25:57 +00:00
2013-09-04 16:48:44 +00:00
def GetWebCookies( self, name ): return self._cookies[ name ]
2013-07-31 21:26:38 +00:00
def GetWrite( self, name ):
write = self._writes[ name ]
del self._writes[ name ]
return write
2013-07-24 20:26:00 +00:00
def Read( self, name ): return self._reads[ name ]
2013-07-10 20:25:57 +00:00
2013-07-31 21:26:38 +00:00
def ReadDaemon( self, name ): return self.Read( name )
2013-07-24 20:26:00 +00:00
def SetRead( self, name, value ): self._reads[ name ] = value
2013-07-10 20:25:57 +00:00
2013-09-04 16:48:44 +00:00
def SetWebCookies( self, name, value ): self._cookies[ name ] = value
2013-07-31 21:26:38 +00:00
def Write( self, name, *args, **kwargs ):
self._writes[ name ].append( ( args, kwargs ) )
2013-08-14 20:21:49 +00:00
def WriteSynchronous( self, name, *args, **kwargs ):
2013-07-31 21:26:38 +00:00
self._writes[ name ].append( ( args, kwargs ) )
if name == 'import_file':
2013-08-07 22:25:18 +00:00
( path, ) = args
with open( path, 'rb' ) as f: file = f.read()
if file == 'blarg': raise Exception( 'File failed to import for some reason!' )
2013-07-31 21:26:38 +00:00
else: return ( 'successful', 'hash' )
2013-07-24 20:26:00 +00:00
if __name__ == '__main__':
2013-07-10 20:25:57 +00:00
2013-07-24 20:26:00 +00:00
app = App()
2013-07-10 20:25:57 +00:00
raw_input()
2013-08-28 21:31:52 +00:00
HC.shutdown = True
HC.pubsub.pubimmediate( 'shutdown' )