示例#1
0
    def test_invalid_backends_config(self):
        obj = StringIO.StringIO("""
            :backends:
                - nope
        """)

        with self.assertRaisesRegexp(Exception, "Invalid Backend: `nope`"):
            piera.Hiera(obj)
示例#2
0
    def test_invalid_hierarchy_config(self):
        obj = StringIO.StringIO("""
            :backends:
                - yaml
        """)

        with self.assertRaisesRegex(Exception, "Invalid Base Hiera Config: missing hierarchy key"):
            piera.Hiera(obj)
示例#3
0
    def test_valid_config(self):
        obj = StringIO.StringIO("""
            :backends:
                - yaml
            :hierarchy:
                - common
            :yaml:
                :datadir: data
        """)

        piera.Hiera(obj)
示例#4
0
import piera
import yaml
import re
import os
from pathlib import Path
import json

#dataPath = "C:\WS_EAODEPLOY3\Sandbox\data"
dataPath = "/Users/gr0005/git/Python/sandbox/data"
heiraFile1 = "sample.yaml"
jsonFile2 = "data2.json"

heiraFull1 = dataPath + "//" + heiraFile1
jsonFile1Full2 = dataPath + "//" + jsonFile2

h = piera.Hiera(heiraFull1)

#x=h.get("George_Key", application='test01')
#print (str(x))
x = h.get("George_Key", application='test01', environment='env03')
print(str(x))
xx = h.get("apps_to_access", application='test01', environment='env01')
print("***************")
print(str(xx))
print("***************")
xx = h.get("MyTest", application='test01', environment='env01')
print("***************")
print(str(xx))
print("***************")
xx = h.get("integer1", application='test01', environment='env01')
print("***************")
示例#5
0
 def test_different_path(self):
     os.chdir("/tmp")
     hiera = piera.Hiera(os.path.join(self.base, 'hiera.yaml'), name='test')
     self.assertEquals(hiera.get('test_basic_get'), 'test_basic_get_works')
     self.assertEquals(hiera.get('test_hierarchy_get'),
                       'test_hierarchy_get_level1')
示例#6
0
    def test_load_empty_config(self):
        obj = StringIO.StringIO("")

        with self.assertRaisesRegexp(
                Exception, "Failed to parse base Hiera configuration"):
            piera.Hiera(obj)
示例#7
0
 def setUp(self):
     self.base = current_dirname
     self.hiera = piera.Hiera(os.path.join(current_dirname, 'hiera.yaml'),
                              name='test')