Пример #1
0
 def setUp(self):
     self.parserInstance=TextLinklistParserMock()
     self.intputQueue=Queue()
     inputCondition=Condition()
     self.files=FilesAdaptorDummy()
     self.bOWUpdaterSimple=BOWUpdaterSimple(self.intputQueue,None,inputCondition,None,filesAdaptor=self.files, parserInstance=self.parserInstance)
     self.bOWUpdaterSimple.settings=SettingsDummy()
     self.bOWUpdaterSimple.debug=DebugMock()
Пример #2
0
class BOWUpdaterTest(unittest.TestCase): 

    def setUp(self):
        self.parserInstance=TextLinklistParserMock()
        self.intputQueue=Queue()
        inputCondition=Condition()
        self.files=FilesAdaptorDummy()
        self.bOWUpdaterSimple=BOWUpdaterSimple(self.intputQueue,None,inputCondition,None,filesAdaptor=self.files, parserInstance=self.parserInstance)
        self.bOWUpdaterSimple.settings=SettingsDummy()
        self.bOWUpdaterSimple.debug=DebugMock()
    
    def tearDown(self):
        del self.bOWUpdaterSimple
        #del self.files        
        
    def test_BOWUpdaterSimple_consume(self): 
        """ BOWUpdaterSimple.consume() returns an instance of a CounterManager. And shorten input queue."""
        # 026 First with empty queue.
        self.assertEqual(self.intputQueue.qsize(), 0)
        item = self.bOWUpdaterSimple.consume()
        self.assertEqual(self.intputQueue.qsize(), 0)
        self.assertIsNone(item)
        # 026 Then with some items in input queue.
        self.intputQueue.put(CounterManager())
        self.intputQueue.put(CounterManager())
        self.assertEqual(self.intputQueue.qsize(), 2)
        item = self.bOWUpdaterSimple.consume()
        self.assertEqual(self.intputQueue.qsize(), 1)
        self.assertTrue(isinstance(item,CounterManager))
        
    def test_BOWUpdaterSimple_verify_incorrect_input(self): 
        """ BOWUpdaterSimple.verifySemiProduct() doesn't accept simple string, SmartURL or another wrong input. """
        self.assertFalse(self.bOWUpdaterSimple.verifySemiProduct("http://www.example.com/page88.html"))
        self.assertFalse(self.bOWUpdaterSimple.verifySemiProduct(None))
        self.assertFalse(self.bOWUpdaterSimple.verifySemiProduct(SmartURL("http://www.example.com/page88.html")))
        # 026 Shall be empty CounterManager correct input?
            
    def test_BOWUpdaterSimple_verify_correct_input(self):  
        """ BOWUpdaterSimple.verifySemiProduct() returns true if called with a CounterManager instance."""
        self.assertTrue(self.bOWUpdaterSimple.verifySemiProduct(CounterManager()))
    
    def test_BOWUpdaterSimple_produce(self): 
        """ BOWUpdaterSimple.produce() """
        # 026 check how many times was called FilesAdaptor.updateBOW()
        cnt=self.files._updateDBcounter
        self.bOWUpdaterSimple.produce(CounterManager())
        cnt2=self.files._updateDBcounter
        self.assertEqual(cnt2-cnt, 1)