コード例 #1
0
    def testSuccessiveRegisterAndRemoveMediator(self):
        """ViewTest: Test Successive registerMediator() and removeMediator()"""
        view = puremvc.core.View.getInstance()

        view.registerMediator(utils.view.ViewTestMediator(self))

        self.assertEqual(
            True,
            isinstance(view.retrieveMediator(utils.view.ViewTestMediator.NAME),
                       utils.view.ViewTestMediator))

        view.removeMediator(utils.view.ViewTestMediator.NAME)

        self.assertEqual(
            True,
            view.retrieveMediator(utils.view.ViewTestMediator.NAME) == None)

        self.assertEqual(
            True,
            view.removeMediator(utils.view.ViewTestMediator.NAME) == None)

        view.registerMediator(utils.view.ViewTestMediator(self))

        self.assertEqual(
            True,
            isinstance(view.retrieveMediator(utils.view.ViewTestMediator.NAME),
                       utils.view.ViewTestMediator))

        view.removeMediator(utils.view.ViewTestMediator.NAME)

        self.assertEqual(
            True,
            view.retrieveMediator(utils.view.ViewTestMediator.NAME) == None)

        self.__cleanup()
コード例 #2
0
ファイル: view.py プロジェクト: Yoriz/python-puremvc
	def testRemoveOneOfTwoMediatorsAndSubsequentNotify(self): 
		"""ViewTest: Test removing one of two Mediators and subsequent notify()"""
		
		view = puremvc.core.View.getInstance()
		
		view.registerMediator(utils.view.ViewTestMediator2(self))
	
		view.registerMediator(utils.view.ViewTestMediator3(self))
	
		view.notifyObservers(puremvc.patterns.observer.Notification(self.NOTE1))
		self.assertEqual(True, self.lastNotification == self.NOTE1)

		view.notifyObservers(puremvc.patterns.observer.Notification(self.NOTE2))
		self.assertEqual(True, self.lastNotification == self.NOTE2)

		view.notifyObservers(puremvc.patterns.observer.Notification(self.NOTE3))
		self.assertEqual(True, self.lastNotification == self.NOTE3)
			
		view.removeMediator(utils.view.ViewTestMediator2.NAME)
		
		self.assertEqual(True, view.retrieveMediator(utils.view.ViewTestMediator2.NAME) == None)

		self.lastNotification = None
	
		view.notifyObservers(puremvc.patterns.observer.Notification(self.NOTE1))
		self.assertEqual(True, self.lastNotification != self.NOTE1)

		view.notifyObservers(puremvc.patterns.observer.Notification(self.NOTE2))
		self.assertEqual(True, self.lastNotification != self.NOTE2)

		view.notifyObservers(puremvc.patterns.observer.Notification(self.NOTE3))
		self.assertEqual(True, self.lastNotification == self.NOTE3)
		
		self.__cleanup()									
コード例 #3
0
    def testMediatorReregistration(self):
        """
        Tests registering the same mediator twice. 
        A subsequent notification should only illicit
        one response. Also, since reregistration
        was causing 2 observers to be created, ensure
        that after removal of the mediator there will
        be no further response.
        
        Added for the fix deployed in version 2.0.4
        """

        view = puremvc.core.View.getInstance()

        view.registerMediator(utils.view.ViewTestMediator5(self))

        # try to register another instance of that mediator (uses the same NAME constant).
        view.registerMediator(utils.view.ViewTestMediator5(self))

        self.counter = 0
        view.notifyObservers(puremvc.patterns.observer.Notification(
            self.NOTE5))
        self.assertEqual(1, self.counter)

        view.removeMediator(utils.view.ViewTestMediator5.NAME)

        self.assertEqual(
            True,
            view.retrieveMediator(utils.view.ViewTestMediator5.NAME) == None)

        self.counter = 0
        view.notifyObservers(puremvc.patterns.observer.Notification(
            self.NOTE5))
        self.assertEqual(0, self.counter)
コード例 #4
0
    def testRemoveMediatorAndSubsequentNotify(self):
        """ViewTest: Test removeMediator() and subsequent nofity()"""

        view = puremvc.core.View.getInstance()

        view.registerMediator(utils.view.ViewTestMediator2(self))

        view.notifyObservers(puremvc.patterns.observer.Notification(
            self.NOTE1))
        self.assertEqual(True, self.lastNotification == self.NOTE1)

        view.notifyObservers(puremvc.patterns.observer.Notification(
            self.NOTE2))
        self.assertEqual(True, self.lastNotification == self.NOTE2)

        view.removeMediator(utils.view.ViewTestMediator2.NAME)

        self.assertEqual(
            True,
            view.retrieveMediator(utils.view.ViewTestMediator2.NAME) == None)

        self.lastNotification = None

        view.notifyObservers(puremvc.patterns.observer.Notification(
            self.NOTE1))
        self.assertEqual(True, self.lastNotification != self.NOTE1)

        view.notifyObservers(puremvc.patterns.observer.Notification(
            self.NOTE2))
        self.assertEqual(True, self.lastNotification != self.NOTE2)

        self.__cleanup()
コード例 #5
0
ファイル: view.py プロジェクト: Yoriz/python-puremvc
	def testRemoveOneOfTwoMediatorsAndSubsequentNotify(self): 
		"""ViewTest: Test removing one of two Mediators and subsequent notify()"""
		
		view = org.puremvc.python.core.View.getInstance()
		
		view.registerMediator(utils.view.ViewTestMediator2(self))
	
		view.registerMediator(utils.view.ViewTestMediator3(self))
	
		view.notifyObservers(org.puremvc.python.patterns.observer.Notification(self.NOTE1))
		self.assertEqual(True, self.lastNotification == self.NOTE1)

		view.notifyObservers(org.puremvc.python.patterns.observer.Notification(self.NOTE2))
		self.assertEqual(True, self.lastNotification == self.NOTE2)

		view.notifyObservers(org.puremvc.python.patterns.observer.Notification(self.NOTE3))
		self.assertEqual(True, self.lastNotification == self.NOTE3)
			
		view.removeMediator(utils.view.ViewTestMediator2.NAME)
		
		self.assertEqual(True, view.retrieveMediator(utils.view.ViewTestMediator2.NAME) == None)

		self.lastNotification = None
	
		view.notifyObservers(org.puremvc.python.patterns.observer.Notification(self.NOTE1))
		self.assertEqual(True, self.lastNotification != self.NOTE1)

		view.notifyObservers(org.puremvc.python.patterns.observer.Notification(self.NOTE2))
		self.assertEqual(True, self.lastNotification != self.NOTE2)

		view.notifyObservers(org.puremvc.python.patterns.observer.Notification(self.NOTE3))
		self.assertEqual(True, self.lastNotification == self.NOTE3)
		
		self.__cleanup()									
コード例 #6
0
ファイル: view.py プロジェクト: Yoriz/python-puremvc
	def testRemoveMediatorAndSubsequentNotify(self): 
		"""ViewTest: Test removeMediator() and subsequent nofity()"""

		view = org.puremvc.python.core.View.getInstance()
	
		view.registerMediator(utils.view.ViewTestMediator2(self))
	
		view.notifyObservers(org.puremvc.python.patterns.observer.Notification(self.NOTE1))
		self.assertEqual(True, self.lastNotification == self.NOTE1)

		view.notifyObservers(org.puremvc.python.patterns.observer.Notification(self.NOTE2))
		self.assertEqual(True, self.lastNotification == self.NOTE2)

		view.removeMediator(utils.view.ViewTestMediator2.NAME)
		
		self.assertEqual(True, view.retrieveMediator(utils.view.ViewTestMediator2.NAME) == None)

		self.lastNotification = None
	
		view.notifyObservers(org.puremvc.python.patterns.observer.Notification(self.NOTE1))
		self.assertEqual(True, self.lastNotification != self.NOTE1)

		view.notifyObservers(org.puremvc.python.patterns.observer.Notification(self.NOTE2))
		self.assertEqual(True, self.lastNotification != self.NOTE2)

		self.__cleanup()									
コード例 #7
0
    def testMediatorReregistration(self):
        """
        Tests registering the same mediator twice.
        A subsequent notification should only illicit
        one response. Also, since reregistration
        was causing 2 observers to be created, ensure
        that after removal of the mediator there will
        be no further response.

        Added for the fix deployed in version 2.0.4
        """

        view = puremvc.core.View.getInstance()

        view.registerMediator(utils.view.ViewTestMediator5(self))

        # try to register another instance of that mediator (uses the same NAME constant).
        view.registerMediator(utils.view.ViewTestMediator5(self))

        self.counter = 0
        view.notifyObservers(puremvc.patterns.observer.Notification(self.NOTE5))
        self.assertEqual(1, self.counter)

        view.removeMediator(utils.view.ViewTestMediator5.NAME)

        self.assertEqual(True, view.retrieveMediator(utils.view.ViewTestMediator5.NAME ) == None)

        self.counter=0
        view.notifyObservers(puremvc.patterns.observer.Notification(self.NOTE5))
        self.assertEqual(0,  self.counter)
コード例 #8
0
ファイル: view.py プロジェクト: Yoriz/python-puremvc
	def testRegisterAndRetrieveMediator(self):
		"""ViewTest: Test registerMediator() and retrieveMediator()"""
		view = puremvc.core.View.getInstance()

		viewTestMediator = utils.view.ViewTestMediator(self)
		view.registerMediator(viewTestMediator)
		
		mediator = view.retrieveMediator(utils.view.ViewTestMediator.NAME)
			
		self.assertEqual(True, isinstance(mediator, utils.view.ViewTestMediator))
		self.__cleanup()
コード例 #9
0
ファイル: view.py プロジェクト: Yoriz/python-puremvc
	def testRegisterAndRetrieveMediator(self):
		"""ViewTest: Test registerMediator() and retrieveMediator()"""
		view = org.puremvc.python.core.View.getInstance()

		viewTestMediator = utils.view.ViewTestMediator(self)
		view.registerMediator(viewTestMediator)
		
		mediator = view.retrieveMediator(utils.view.ViewTestMediator.NAME)
			
		self.assertEqual(True, isinstance(mediator, utils.view.ViewTestMediator))
		self.__cleanup()
コード例 #10
0
ファイル: view.py プロジェクト: Yoriz/python-puremvc
	def testRegisterAndRemoveMediator(self):
		"""ViewTest: Test registerMediator() and removeMediator()"""
		view = puremvc.core.View.getInstance()

		meditr = puremvc.patterns.mediator.Mediator('testing', self)
		view.registerMediator(meditr)

		removedMediator = view.removeMediator('testing')

		self.assertEqual(True, removedMediator.getMediatorName() == 'testing')

		self.assertEqual(True, view.retrieveMediator('testing') == None)
		self.__cleanup()
コード例 #11
0
    def testRegisterAndRemoveMediator(self):
        """ViewTest: Test registerMediator() and removeMediator()"""
        view = puremvc.core.View.getInstance()

        meditr = puremvc.patterns.mediator.Mediator('testing', self)
        view.registerMediator(meditr)

        removedMediator = view.removeMediator('testing')

        self.assertEqual(True, removedMediator.getMediatorName() == 'testing')

        self.assertEqual(True, view.retrieveMediator('testing') == None)
        self.__cleanup()
コード例 #12
0
ファイル: view.py プロジェクト: Yoriz/python-puremvc
	def testSuccessiveRegisterAndRemoveMediator(self):
		"""ViewTest: Test Successive registerMediator() and removeMediator()"""
		view = puremvc.core.View.getInstance()

		view.registerMediator(utils.view.ViewTestMediator(self))
	
		self.assertEqual(True, isinstance(view.retrieveMediator(utils.view.ViewTestMediator.NAME), utils.view.ViewTestMediator))

		view.removeMediator(utils.view.ViewTestMediator.NAME)
		
		self.assertEqual(True, view.retrieveMediator(utils.view.ViewTestMediator.NAME) == None)
	
		self.assertEqual(True, view.removeMediator(utils.view.ViewTestMediator.NAME) == None)

		view.registerMediator(utils.view.ViewTestMediator(self))
	
		self.assertEqual(True, isinstance(view.retrieveMediator(utils.view.ViewTestMediator.NAME), utils.view.ViewTestMediator))

		view.removeMediator(utils.view.ViewTestMediator.NAME)
			
		self.assertEqual(True, view.retrieveMediator(utils.view.ViewTestMediator.NAME) == None)

		self.__cleanup()