~ubuntu-branches/ubuntu/natty/computer-janitor/natty

« back to all changes in this revision

Viewing changes to plugins/landscape_stub_plugin_tests.py

  • Committer: Bazaar Package Importer
  • Author(s): Barry Warsaw, Martin Pitt, Barry Warsaw
  • Date: 2011-02-16 15:58:36 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110216155836-gierzoufmyflfdcc
Tags: 2.1.0-0ubuntu1
[ Martin Pitt ]
* data/ComputerJanitor.ui: Drop obsolete has_separator properties.
* run_from_checkout.sh: Drop setting of $PYTHONPATH. Current directory is
  there by default anyway, and this breaks setting it from the environment.
* computerjanitorapp/gtk/*: Port from pygtk2 to pygi. Works fully with GTK3
  now, with GTK2 we need to disable the right-click popup menu
  (popup_for_device() is introspection safe, but only exists in GTK3.
  popup() isn't introspectable).
* computerjanitorapp/gtk/ui.py: Force GTK2 for now, as we do not yet have a
  GTK3 theme in Natty, and don't carry the GTK3 stack in the default
  install.
* debian/control: Update dependencies for the pygtk → pygi switch.
* debian/control: Drop obsolete system-cleaner conflicts and gksu
  dependency.

[ Barry Warsaw ]
* Add Edit menu items for selecting and deselecting cruft.
* Bump version number.
* Update copyright years.
* Python style, whitespace, and import cleanups.
* Print error messages via logger instead of stderr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# landscape_stub_removal.py 
2
 
# Copyright (C) 2009  Canonical, Ltd.
 
1
# landscape_stub_removal.py
 
2
#
 
3
# Copyright (C) 2009-2011  Canonical, Ltd.
3
4
#
4
5
# Author: Michael Vogt <mvo@ubuntu.com>
5
6
#
16
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18
 
18
19
 
19
 
import os
20
 
import tempfile
21
20
import unittest
22
21
 
23
22
import landscape_stub_plugin
24
23
 
 
24
 
25
25
class MockAptPackage(object):
26
 
 
27
 
    def __init__(self, name, installed=True, downloadable=True, installedVersion=""):
 
26
    def __init__(self, name, installed=True, downloadable=True,
 
27
                 installedVersion=""):
28
28
        self.name = name
29
29
        self.isInstalled = installed
30
30
        self.installedDownloadable = downloadable
38
38
    def markKeep(self):
39
39
        self.markedKeep = True
40
40
 
 
41
 
41
42
class MockAptCache(dict):
42
 
 
43
43
    def add(self, name, **kwargs):
44
44
        self[name] = MockAptPackage(name, **kwargs)
 
45
 
45
46
    def __iter__(self):
46
47
        for pkg in self.values():
47
48
            yield pkg
 
49
 
48
50
    def markRemove(self, pkgname, reason):
49
51
        self[pkgname].markedRemove = True
 
52
 
50
53
    def markInstall(self, pkgname, reason):
51
54
        self[pkgname].markedInstall = True
52
 
        
 
55
 
 
56
 
53
57
class MockApplication(object):
54
 
 
55
58
    def __init__(self):
56
59
        self.apt_cache = MockAptCache()
57
60
        self.serverMode = False
58
61
 
59
62
 
60
63
class LandscapeStubPluginTests(unittest.TestCase):
61
 
 
62
64
    def setUp(self):
63
65
        self.plugin = landscape_stub_plugin.LandscapeStubPlugin()
64
66
        self.plugin.set_application(MockApplication())
75
77
        self.assertEqual(sorted(names), sorted([u"deb:landscape-client"]))
76
78
        cruft = self.plugin.get_cruft().next()
77
79
        cruft.cleanup()
78
 
        self.assertEqual(self.plugin.app.apt_cache["landscape-client"].markedRemove, True)
79
 
        self.assertEqual(self.plugin.app.apt_cache["landscape-client"].markedInstall, False)
80
 
        self.assertEqual(self.plugin.app.apt_cache["landscape-common"].markedKeep, True)
81
 
        self.assertEqual(self.plugin.app.apt_cache["landscape-common"].markedInstall, True)
 
80
        self.assertEqual(
 
81
            self.plugin.app.apt_cache["landscape-client"].markedRemove, True)
 
82
        self.assertEqual(
 
83
            self.plugin.app.apt_cache["landscape-client"].markedInstall, False)
 
84
        self.assertEqual(
 
85
            self.plugin.app.apt_cache["landscape-common"].markedKeep, True)
 
86
        self.assertEqual(
 
87
            self.plugin.app.apt_cache["landscape-common"].markedInstall, True)