~straemer/ubuntu/quantal/update-manager/fix-for-1058070

« back to all changes in this revision

Viewing changes to tests/test_changelog.py

  • Committer: Package Import Robot
  • Author(s): Michael Terry
  • Date: 2012-06-29 10:59:30 UTC
  • mfrom: (389.1.2 precise-security)
  • Revision ID: package-import@ubuntu.com-20120629105930-0oaj9vdvykmvkjum
Tags: 1:0.165
* Implementation of "update on start" feature from spec
  https://wiki.ubuntu.com/SoftwareUpdates
* Use a single main window that changes instead of having modal dialogs
* Implement several special-purpose dialogs like "No updates" or
  "Dist upgrade needed" accordingn to the above spec
* Split out release upgrader code and DistUpgrade module into a separate
  source package
* Drop python-update-manager, as it is unused
* debian/tests:
  - Add dep8 tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
 
1
#!/usr/bin/python3
 
2
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
3
3
 
4
4
import apt
5
5
import logging
10
10
except ImportError:
11
11
    from urllib2 import HTTPError
12
12
 
13
 
sys.path.insert(0, "../")
14
13
from UpdateManager.Core.MyCache import MyCache
15
14
 
 
15
 
16
16
class TestChangelogs(unittest.TestCase):
17
17
 
18
18
    def setUp(self):
30
30
        self.assertTrue("gcc-defaults_" in uri)
31
31
        self.assertTrue(uri.endswith(".changelog"))
32
32
        # and one without a "Source" entry, we don't find something here
33
 
        self.assertEqual(self.cache._guess_third_party_changelogs_uri_by_source("apt"), None)
 
33
        uri = self.cache._guess_third_party_changelogs_uri_by_source("apt")
 
34
        self.assertEqual(uri, None)
34
35
        # one with srcver == binver
35
36
        pkgname = "libgtk2.0-dev"
36
37
        uri = self.cache._guess_third_party_changelogs_uri_by_source(pkgname)
43
44
            with open("/dev/zero") as zero:
44
45
                raise HTTPError(
45
46
                    "url", "code", "msg", "hdrs", zero)
46
 
        pkgname = "update-manager"
 
47
        pkgname = "gcc"
47
48
        # patch origin
48
49
        real_origin = self.cache.CHANGELOG_ORIGIN
49
50
        self.cache.CHANGELOG_ORIGIN = "xxx"
51
52
        self.cache._get_changelog_or_news = monkey_patched_get_changelogs
52
53
        # get changelog
53
54
        self.cache.get_changelog(pkgname)
54
 
        error = "This update does not come from a source that supports changelogs."
 
55
        error = "This update does not come from a source that "
 
56
        error += "supports changelogs."
55
57
        # verify that we don't have the lines twice
56
 
        self.assertEqual(self.cache.all_changes[pkgname].split("\n")[-1], error)
 
58
        self.assertEqual(self.cache.all_changes[pkgname].split("\n")[-1],
 
59
                         error)
57
60
        self.assertEqual(len(self.cache.all_changes[pkgname].split("\n")), 5)
58
61
        self.assertEqual(self.cache.all_changes[pkgname].count(error), 1)
59
62
        self.cache.CHANGELOG_ORIGIN = real_origin
62
65
    if len(sys.argv) > 1 and sys.argv[1] == "-v":
63
66
        logging.basicConfig(level=logging.DEBUG)
64
67
    unittest.main()
65
 
    
66