home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / pyshared / computerjanitor / cruft_tests.py < prev    next >
Encoding:
Python Source  |  2009-04-27  |  2.0 KB  |  57 lines

  1. # cruft_tests.py - unit tests for cruft.py
  2. # Copyright (C) 2008  Canonical, Ltd.
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, version 3 of the License.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  15.  
  16.  
  17. import unittest
  18.  
  19. import computerjanitor
  20.  
  21.  
  22. class CruftTests(unittest.TestCase):
  23.  
  24.     def setUp(self):
  25.         self.cruft = computerjanitor.Cruft()
  26.  
  27.     def testReturnsClassNameAsDefaultPrefix(self):
  28.         class Mockup(computerjanitor.Cruft):
  29.             pass
  30.         self.assertEqual(Mockup().get_prefix(), "Mockup")
  31.  
  32.     def testReturnsEmptyStringAsDefaultPrefixDescription(self):
  33.         self.assertEqual(self.cruft.get_prefix_description(), "")
  34.  
  35.     def testReturnsDescriptionAsDefaultPrefixDescription(self):
  36.         self.cruft.get_description = lambda: "foo"
  37.         self.assertEqual(self.cruft.get_prefix_description(), "foo")
  38.  
  39.     def testRaisesErrorForDefaultGetShortname(self):
  40.         self.assertRaises(computerjanitor.UnimplementedMethod,
  41.                           self.cruft.get_shortname)
  42.  
  43.     def testReturnsCorrectStringForFullName(self):
  44.         self.cruft.get_prefix = lambda *args: "foo"
  45.         self.cruft.get_shortname = lambda *args: "bar"
  46.         self.assertEqual(self.cruft.get_name(), "foo:bar")
  47.  
  48.     def testReturnsEmptyStringAsDefaultDescription(self):
  49.         self.assertEqual(self.cruft.get_description(), "")
  50.  
  51.     def testReturnsNoneForDiskUsage(self):
  52.         self.assertEqual(self.cruft.get_disk_usage(), None)
  53.  
  54.     def testRaisesErrorForDefaultCleanup(self):
  55.         self.assertRaises(computerjanitor.UnimplementedMethod,
  56.                           self.cruft.cleanup)
  57.