1
# package_cruft_tests.py - unit tests for package_cruft.py
2
# Copyright (C) 2008 Canonical, Ltd.
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.
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.
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/>.
19
import computerjanitor
22
class MockAptPackage(object):
26
self.summary = "summary"
27
self.installedSize = 12765
34
class PackageCruftTests(unittest.TestCase):
37
self.pkg = MockAptPackage()
38
self.cruft = computerjanitor.PackageCruft(self.pkg, "description")
40
def testReturnsCorrectPrefix(self):
41
self.assertEqual(self.cruft.get_prefix(), "deb")
43
def testReturnsCorrectPrefixDescription(self):
44
self.assertEqual(self.cruft.get_prefix_description(), ".deb package")
46
def testReturnsCorrectShortname(self):
47
self.assertEqual(self.cruft.get_shortname(), "name")
49
def testReturnsCorrectName(self):
50
self.assertEqual(self.cruft.get_name(), "deb:name")
52
def testReturnsCorrectDescription(self):
53
self.assertEqual(self.cruft.get_description(),
54
"description\n\nsummary")
56
def testReturnsCorrectDiskUsage(self):
57
self.assertEqual(self.cruft.get_disk_usage(), 12765)
59
def testDeletesPackage(self):
61
self.assertTrue(self.pkg.deleted)