예제 #1
0
    def test_01__defaults_w_modified_env(self):
        dfs_ref = C._defaults(E.Env())

        env = E.Env()
        env.workdir = "/a/b/c"  # modified.

        dfs = C._defaults(E.Env())

        self.assertNotEquals(dfs_ref, dfs)
        self.assertEquals(dfs.workdir, env.workdir)
예제 #2
0
    def test_02__norc_and_load_yaml_config(self):
        if E.yaml is None:
            return True

        cfg = C.Config(norc=True)
        dfs = C._defaults(E.Env())
        config = os.path.join(self.workdir, "test_config.yaml")

        content = """
verbosity: 1
input_type: filelist.yaml
summary: YAML Configuration test
ignore_owner: true
no_mock: true
files:
    - path: /a/b/c
      attrs:
        create: true
        install_path: /a/c
        uid: 100
        gid: 0
        rpmattr: "%config(noreplace)"
"""
        open(config, "w").write(content)
        cfg.load(config)

        self.assertEquals(cfg.verbosity, 1)
        self.assertEquals(cfg.input_type, "filelist.yaml")
        self.assertEquals(cfg.summary, "YAML Configuration test")
        self.assertEquals(cfg.ignore_owner, True)
        self.assertEquals(cfg.no_mock, True)

        self.assertNotEquals(cfg.files, None)
        self.assertFalse(cfg.missing_files())
예제 #3
0
    def test_00__init__w_norc(self):
        cfg = C.Config(norc=True)
        dfs = C._defaults(E.Env())  # reference of cfg.

        for k, v in dfs.iteritems():
            self.assertEquals(getattr(cfg, k), v)

        self.assertTrue(cfg.missing_files())
예제 #4
0
    def test_00__init__(self):
        o = O.Options()

        # pmaker.options.Options is not resolvable because it would be hide
        # (decorated) with pmaker.utils.singleton() if it's decorated with
        # singleton() (@singleton). Here we use Bunch (parent class of Options
        # class) instead in such cases:
        # self.assertTrue(isinstance(o, Bunch))
        ## pmaker.options.Options is now not singleton:
        self.assertTrue(isinstance(o, O.Options))

        dfs = o.get_defaults()

        for k, v in C._defaults(E.Env()).iteritems():
            self.assertEquals(dfs[k], v)
예제 #5
0
    def test_01__norc_and_load_json_config(self):
        if E.json is None:
            return True

        cfg = C.Config(norc=True)
        dfs = C._defaults(E.Env())
        config = os.path.join(self.workdir, "test_config.json")

        content = """
{
    "verbosity": 1,
    "input_type": "filelist.json",
    "summary": "JSON Configuration test",
    "ignore_owner": true,
    "no_mock": true,
    "files": [
        {
            "path": "/a/b/c",
            "attrs" : {
                "create": true,
                "install_path": "/a/c",
                "uid": 100,
                "gid": 0,
                "rpmattr": "%config(noreplace)"
            }
        }
    ]
}
"""
        open(config, "w").write(content)
        cfg.load(config)

        self.assertEquals(cfg.verbosity, 1)
        self.assertEquals(cfg.input_type, "filelist.json")
        self.assertEquals(cfg.summary, "JSON Configuration test")
        self.assertEquals(cfg.ignore_owner, True)
        self.assertEquals(cfg.no_mock, True)

        self.assertNotEquals(cfg.files, None)
        self.assertFalse(cfg.missing_files())
예제 #6
0
    def test_00__defaults(self):
        dfs = C._defaults(E.Env())

        self.assertTrue(isinstance(dfs, B.Bunch))