old_contents: #!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  import unittest
  
  import os, sys
  sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  
  from DebianChangesBot import Datasource
  from DebianChangesBot.datasources import NewQueue
  
  class TestDatasourceTestingRCBugs(unittest.TestCase):
  
      def setUp(self):
          self.fixture = os.path.join(os.path.dirname(os.path.abspath(__file__)), \
              'fixtures', 'new_queue.html')
  
          self.datasource = NewQueue()
  
      def parse(self):
          fileobj = open(self.fixture)
          return self.datasource.parse(fileobj)
  
      def testURL(self):
          """
          Check we have a sane URL.
          """
          self.assert_(len(self.datasource.URL) > 5)
          self.assert_(self.datasource.URL.startswith('http'))
  
      def testInterval(self):
          """
          Check we have a sane update interval.
          """
          self.assert_(self.datasource.INTERVAL > 60)
  
      def testType(self):
          val = self.parse()
          iter(val)
  
      def testElemTypes(self):
          val = self.parse()
          for package in val:
              self.assertEqual(type(package), str)
  
      def testLength(self):
          val = self.parse()
          self.assertEqual(len(val), 110)
  
  
  if __name__ == "__main__":
      unittest.main()
  
new_contents: #!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  import unittest
  
  import os, sys
  sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  
  from DebianChangesBot import Datasource
  from DebianChangesBot.datasources import NewQueue
  
  class TestDatasourceTestingRCBugs(unittest.TestCase):
  
      def setUp(self):
          self.fixture = os.path.join(os.path.dirname(os.path.abspath(__file__)), \
              'fixtures', 'new_queue.html')
  
          self.datasource = NewQueue()
  
      def is_new(self, package):
          fileobj = open(self.fixture)
          self.datasource.update(fileobj)
          return self.datasource.is_new(package)
  
      def testURL(self):
          """
          Check we have a sane URL.
          """
          self.assert_(len(self.datasource.URL) > 5)
          self.assert_(self.datasource.URL.startswith('http'))
  
      def testInterval(self):
          """
          Check we have a sane update interval.
          """
          self.assert_(self.datasource.INTERVAL > 60)
  
      def testParseEmpty(self):
          fileobj = open('/dev/null')
          self.assertRaises(Datasource.DataError, self.datasource.update, fileobj)
  
      def testTop(self):
          self.assert_(self.is_new('ganeti-instance-debian-etch'))
  
      def testBottom(self):
          self.assert_(self.is_new('sugar-chat-activity'))
  
      def testMultipleVersions(self):
          self.assert_(self.is_new('cpushare'))
  
      def testNotInQueue(self):
          self.failIf(self.is_new('package-not-in-new-queue'))
  
      def testByhand(self):
          self.assert_(self.is_new('loadlin'))
  
      def testExperimental(self):
          self.assert_(self.is_new('tagua'))
  
  if __name__ == "__main__":
      unittest.main()
  
subject: Update NewQueue tests