From 1673551ce751e993e7f3a2822b3fc86e8cbdd5eb Mon Sep 17 00:00:00 2001 From: Hidekazu Nakamura Date: Fri, 22 Jul 2016 16:40:47 +0900 Subject: [PATCH] Chef executor unit tests now compare dicts instead of strings Before this patch tests used to compare json.dumps representation of dicts. This can lead to false negatives. This patch fixes to test to compare objects instead. Closes-Bug: #1610181 Co-Authored-By: Kirill Zaitsev Change-Id: I69af1c017362f95b92a81af3212f6520e7b4ceba --- muranoagent/tests/unit/executors/test_chef.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/muranoagent/tests/unit/executors/test_chef.py b/muranoagent/tests/unit/executors/test_chef.py index 06babd0a..1cecc641 100644 --- a/muranoagent/tests/unit/executors/test_chef.py +++ b/muranoagent/tests/unit/executors/test_chef.py @@ -36,7 +36,7 @@ class TestChefExecutor(base.MuranoAgentTestCase, fixtures.TestWithFixtures): def test_create_nodejson_noatts(self): """It tests the manifest without attributes.""" node = self.chef_executor._create_manifest('cookbook', 'recipe', None) - self.assertEqual(node, self.get_nodejs_no_atts()) + self.assertEqual(json.loads(node), self.get_node_no_atts()) def test_create_nodejson(self): """It tests a manifest with attributes.""" @@ -46,7 +46,7 @@ class TestChefExecutor(base.MuranoAgentTestCase, fixtures.TestWithFixtures): } node = self.chef_executor._create_manifest('cookbook', 'recipe', atts) - self.assertEqual(node, self.get_nodejs_atts()) + self.assertEqual(json.loads(node), self.get_node_atts()) @mock.patch('subprocess.Popen') @mock.patch('six.moves.builtins.open') @@ -243,8 +243,8 @@ class TestChefExecutor(base.MuranoAgentTestCase, fixtures.TestWithFixtures): } ) - def get_nodejs_atts(self): - return json.dumps({ + def get_node_atts(self): + return { "run_list": [ "recipe[cookbook::recipe]" ], @@ -252,11 +252,11 @@ class TestChefExecutor(base.MuranoAgentTestCase, fixtures.TestWithFixtures): "att1": "value1", "att2": "value2" } - }) + } - def get_nodejs_no_atts(self): - return json.dumps({ + def get_node_no_atts(self): + return { "run_list": [ "recipe[cookbook::recipe]" ] - }) + }