1 # Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
16 from __future__ import print_function
22 from pbr.hooks import files
23 from pbr.tests import base
26 class FilesConfigTest(base.BaseTestCase):
29 super(FilesConfigTest, self).setUp()
31 pkg_fixture = fixtures.PythonPackage(
33 ("fake_module.py", b""),
34 ("other_fake_module.py", b""),
36 self.useFixture(pkg_fixture)
37 pkg_etc = os.path.join(pkg_fixture.base, 'etc')
38 pkg_sub = os.path.join(pkg_etc, 'sub')
39 subpackage = os.path.join(
40 pkg_fixture.base, 'fake_package', 'subpackage')
42 os.makedirs(subpackage)
43 with open(os.path.join(pkg_etc, "foo"), 'w') as foo_file:
44 foo_file.write("Foo Data")
45 with open(os.path.join(pkg_sub, "bar"), 'w') as foo_file:
46 foo_file.write("Bar Data")
47 with open(os.path.join(subpackage, "__init__.py"), 'w') as foo_file:
48 foo_file.write("# empty")
50 self.useFixture(base.DiveDir(pkg_fixture.base))
52 def test_implicit_auto_package(self):
57 files.FilesConfig(config, 'fake_package').run()
58 self.assertIn('subpackage', config['files']['packages'])
60 def test_auto_package(self):
63 packages='fake_package',
66 files.FilesConfig(config, 'fake_package').run()
67 self.assertIn('subpackage', config['files']['packages'])
69 def test_data_files_globbing(self):
72 data_files="\n etc/pbr = etc/*"
75 files.FilesConfig(config, 'fake_package').run()
77 '\netc/pbr/ = \n etc/foo\netc/pbr/sub = \n etc/sub/bar',
78 config['files']['data_files'])