Enhance policy test for init()

As suggested by Doug, let's write real data and see if they were read.

Change-Id: If709b36634b4352ce7e5a3d40b58bfba0f9ae91d
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2013-01-11 16:31:11 +01:00
parent f24e09d76a
commit 8b8981ab8e

View File

@ -39,11 +39,13 @@ class TestPolicy(base.TestCase):
pass
def test_init(self):
json_data = "{\"is_fun\": [[\"role:clown\"]]}"
cfg.CONF([])
cfg.CONF.policy_file = tempfile.mktemp()
with open(cfg.CONF.policy_file, "w") as f:
f.write("{}")
f.write(json_data)
policy.init()
self.assertEqual(policy._POLICY_CACHE['data'], json_data)
def test_init_file_not_found(self):
cfg.CONF([])