vc.venueCache.Update() vc.venueCache.Store() """ # If user has no stored bridges, initialize the bridge cache bridges = app.preferences.GetBridges() if not bridges: # Initialize bridge cache vc.LoadBridges(progressDialog.UpdateGauge) vcui = VenueClientUI(vc, vcc, app, progressDialog.UpdateGauge) vc.SetVCUI(vcui) # Associate the components with the ui vcc.SetGui(vcui) vc.AddObserver(vcui) # Check multicast status, set to use unicast appropriately progressDialog.UpdateGauge('Analyzing Network', 100) multicastStatus = vc.GetMulticastStatus() vcui.SetMcastStatus(multicastStatus) log.info("Multicast Status at startup: %d", multicastStatus) if multicastStatus == 0: vcui.UseUnicastCB() if isFirstRun: app.preferences.SetPreference(Preferences.MULTICAST, multicastStatus) app.preferences.StorePreferences() vcui.venueAddressBar.SetAddress(app.preferences.GetProfile().homeVenue)
class SystemTest: def __init__(self): # Init the toolkit with the standard environment. self.app = WXGUIApplication() # Try to initialize args = self.app.Initialize("VenueClient", sys.argv[:1]) # Handle command line options self.__buildOptions() if not self.port: self.port = 8000 if not self.url: self.url = 'https://localhost:8000/Venues/default' # Create venue client components self.vc = VenueClient(pnode=self.pnode, port=self.port) self.vcc = VenueClientController() self.vcc.gui = Gui() self.vcc.SetVenueClient(self.vc) self.observer = Observer() self.vc.AddObserver(self.observer) # Start tests self.__StartTests() # Exit self.vc.Shutdown() sys.exit(0) def __StartTests(self): # ------------------------------------- # EnterVenue # ------------------------------------- self.__testMethod(self.vc.EnterVenue, "EnterVenue", args = [self.url]) # ------------------------------------- # Services # ------------------------------------- # AddService service = ServiceDescription("test", "test", "test", "test") service.SetId(5) self.__testMethod(self.vc.AddService, "AddService", args = [service]) s = self.observer.lastService if not s.id == service.id: print 'Add Service FAILED; service does not exist' # UpdateService service.SetName("Updated Service") self.__testMethod(self.vc.UpdateService, "UpdateService", args = [service]) # RemoveService self.__testMethod(self.vc.RemoveService, "RemoveService", args = [service]) # ------------------------------------- # Data # ------------------------------------- # AddData file1 = os.path.join(os.getcwd(), 'unittest_all.py') file2 = os.path.join(os.getcwd(), 'unittest_ClientProfile.py') self.__testMethod(self.vcc.UploadVenueFiles, "UploadVenueFiles", args = [[file1,file2]]) time.sleep(20) d = self.observer.lastData d.SetName("Updated Name") # ModifyData self.__testMethod(self.vc.ModifyData, "ModifyData", args = [d]) # RemoveData # ------------------------------------- # Applications # ------------------------------------- # CreateApplication name = 'Test App' self.__testMethod(self.vc.CreateApplication, "CreateApplication", args = ['Test App', "my_desc", 'my_mime']) app = self.observer.lastApplication if not app.name == name: print 'Create Application Failed; app does not exist' # UpdateApplication app.SetName("Updated Application") self.__testMethod(self.vc.UpdateApplication, "UpdateApplication", args = [app]) # DestroyApplication self.__testMethod(self.vc.DestroyApplication, "DestroyApplication", args = [app.id]) # -------------------------------------- # ExitVenue # -------------------------------------- self.__testMethod(self.vc.ExitVenue, 'ExitVenue') def __testMethod(self, method, text, args = None): print '******************************************' try: if args: return apply(method, args) else: return apply(method) print '%s SUCCEEDED'%text except: print '%s FAILED'%text print '******************************************' def __buildOptions(self): # build options for this application portOption = Option("-p", "--port", type="int", dest="port", default=0, metavar="PORT", help="Set the port the venueclient control interface\ should listen on.") self.app.AddCmdLineOption(portOption) pnodeOption = Option("--personalNode", action="store_true", dest="pnode", default=0, help="Run NodeService and ServiceManager with the client.") self.app.AddCmdLineOption(pnodeOption) urlOption = Option("--url", type="string", dest="url", default="", metavar="URL", help="URL of venue to enter on startup.") self.app.AddCmdLineOption(urlOption) self.log = self.app.GetLog() self.pnode = self.app.GetOption("pnode") self.url = self.app.GetOption("url") self.port = self.app.GetOption("port")