~ubuntubugs-aiki-it/computer-janitor/bug-726616

« back to all changes in this revision

Viewing changes to plugins/dpkg_dotfile_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
1
# dpkg_dotfile_plugin_tests.py - unittests for dpkg_dotfile_plugin.py
2
 
# Copyright (C) 2009  Canonical, Ltd.
 
2
#
 
3
# Copyright (C) 2009-2011  Canonical, Ltd.
3
4
#
4
5
# This program is free software: you can redistribute it and/or modify
5
6
# it under the terms of the GNU General Public License as published by
26
27
 
27
28
    def setUp(self):
28
29
        self.plugin = dpkg_dotfile_plugin.DpkgDotfilePlugin()
29
 
        
 
30
 
30
31
        self.root = tempfile.mkdtemp()
31
32
        self.empty = self.makedir("empty")
32
33
        self.etc = self.makedir("etc")
35
36
        self.dpkg_new = self.create_file(self.subdir, "foo.dpkg-new")
36
37
        self.dpkg_dir = self.makedir("etc/subdir.dpkg-old")
37
38
        filename = self.create_file(self.etc, "foo")
38
 
        self.dpkg_sym = self.create_symlink(filename, 
 
39
        self.dpkg_sym = self.create_symlink(filename,
39
40
                                            self.etc, "foobar.dpkg-old")
40
41
        self.create_file(self.etc, "foo")
41
 
        
 
42
 
42
43
    def makedir(self, name):
43
44
        path = os.path.join(self.root, name)
44
45
        os.mkdir(path)
53
54
        path = os.path.join(dirname, linkname)
54
55
        os.symlink(existing, path)
55
56
        return path
56
 
        
 
57
 
57
58
    def tearDown(self):
58
59
        shutil.rmtree(self.root)
59
60
 
60
61
    def test_directories_set_to_etc_by_default(self):
61
62
        # This test is here so that nobody changes the default list by
62
63
        # mistake, without realizing that it is important.
63
 
        self.assertEqual(sorted(self.plugin.dirs), 
 
64
        self.assertEqual(sorted(self.plugin.dirs),
64
65
                         sorted(["/etc",
65
66
                                 "/var/ax25",
66
67
                                 "/var/cache/roxen4",
101
102
 
102
103
    def test_get_cruft_returns_the_right_stuff(self):
103
104
        self.plugin.dirs = [self.empty, self.etc]
104
 
        self.assertEqual(sorted([x.get_shortname() 
 
105
        self.assertEqual(sorted([x.get_shortname()
105
106
                                 for x in self.plugin.get_cruft()]),
106
107
                         sorted([self.dpkg_old, self.dpkg_new]))