def test_invalid_backends_config(self): obj = StringIO.StringIO(""" :backends: - nope """) with self.assertRaisesRegexp(Exception, "Invalid Backend: `nope`"): piera.Hiera(obj)
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)
def test_valid_config(self): obj = StringIO.StringIO(""" :backends: - yaml :hierarchy: - common :yaml: :datadir: data """) piera.Hiera(obj)
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("***************")
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')
def test_load_empty_config(self): obj = StringIO.StringIO("") with self.assertRaisesRegexp( Exception, "Failed to parse base Hiera configuration"): piera.Hiera(obj)
def setUp(self): self.base = current_dirname self.hiera = piera.Hiera(os.path.join(current_dirname, 'hiera.yaml'), name='test')