~celebdor/charms/trusty/neutron-agents-midonet/trunk

« back to all changes in this revision

Viewing changes to unit_tests/test_context.py

  • Committer: James Page
  • Date: 2016-02-16 09:58:45 UTC
  • Revision ID: james.page@ubuntu.com-20160216095845-vdpn1yylsi0fxe8l
Fully mock out unit tests from underlying os

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
        test.CharmTestCase.setUp(self, services.hookenv, HOOKENV_PATCHES)
61
61
 
62
62
        def lsb_release():
63
 
            ubuntu_trusty = {
 
63
            return {
64
64
                'DISTRIB_ID': 'Ubuntu',
65
65
                'DISTRIB_RELEASE': '14.04',
66
66
                'DISTRIB_CODENAME': 'trusty',
67
67
                'DISTRIB_DESCRIPTION': "Ubuntu 14.04.3 LTS",
68
68
            }
69
69
 
70
 
            try:
71
 
                data = services.host.lsb_release()
72
 
            except Exception:
73
 
                return ubuntu_trusty
74
 
            if data.get('DISTRIB_ID') != 'Ubuntu':
75
 
                return ubuntu_trusty
76
 
            return data
77
 
 
78
70
        def get_os_codename_package(pkg, fatal=True):
79
 
            version = 'liberty'
80
 
            try:
81
 
                ret_vers = services.utils.get_os_codename_package(pkg, fatal)
82
 
            except Exception:
83
 
                return version
84
 
            return ret_vers
 
71
            return 'liberty'
85
72
 
86
73
        self.patch_all(services.utils,
87
74
                       ('get_os_codename_package',