def test_release_file(self):
        version.loaded = False
        real_open = builtins.open
        real_find_file = cfg.CONF.find_file

        def fake_find_file(self, name):
            if name == "release":
                return "/etc/nova/release"
            return real_find_file(self, name)

        def fake_open(path, *args, **kwargs):
            if path == "/etc/nova/release":
                data = """[Nova]
vendor = ACME Corporation
product = ACME Nova
package = 1337"""
                return six.StringIO(data)

            return real_open(path, *args, **kwargs)

        self.stubs.Set(builtins, 'open', fake_open)
        self.stubs.Set(cfg.ConfigOpts, 'find_file', fake_find_file)

        self.assertEqual(version.vendor_string(), "ACME Corporation")
        self.assertEqual(version.product_string(), "ACME Nova")
        self.assertEqual(version.package_string(), "1337")
Exemple #2
0
    def test_release_file(self):
        version.loaded = False
        real_open = __builtin__.open
        real_find_file = cfg.CONF.find_file

        def fake_find_file(self, name):
            if name == "release":
                return "/etc/nova/release"
            return real_find_file(self, name)

        def fake_open(path, *args, **kwargs):
            if path == "/etc/nova/release":
                data = """[Nova]
vendor = ACME Corporation
product = ACME Nova
package = 1337"""
                return StringIO.StringIO(data)

            return real_open(path, *args, **kwargs)

        self.stubs.Set(__builtin__, 'open', fake_open)
        self.stubs.Set(cfg.ConfigOpts, 'find_file', fake_find_file)

        self.assertEqual(version.vendor_string(), "ACME Corporation")
        self.assertEqual(version.product_string(), "ACME Nova")
        self.assertEqual(version.package_string(), "1337")
    def test_release_file(self):
        version.loaded = False
        real_find_file = cfg.CONF.find_file

        def fake_find_file(self, name):
            if name == "release":
                return "/etc/nova/release"
            return real_find_file(self, name)

        self.stub_out('oslo_config.cfg.ConfigOpts.find_file', fake_find_file)

        self.assertEqual(version.vendor_string(), "ACME Corporation")
        self.assertEqual(version.product_string(), "ACME Nova")
        self.assertEqual(version.package_string(), "1337")