Example #1
0
 def test_missing_node_data_json_error(self):
     """Should raise RepoError when there is a JSON error"""
     nodes = chef._load_data("nodes")  # Load before mocking
     with patch.object(json, 'loads') as mock_method:
         mock_method.side_effect = json.decoder.JSONDecodeError(
             "JSON syntax error", "", 10)
         self.assertRaises(chef.RepoError, chef._load_extended_node_data,
                           nodes)
Example #2
0
 def test_load_data_unsupported(self):
     """Should return None when an invalid arg is given"""
     self.assertEqual(chef._load_data('rolezzzz'), None)
Example #3
0
 def test_load_data_roles(self):
     """Should return roles when the given argument is 'roles'"""
     data = chef._load_data('roles')
     self.assertEqual(len(data), 4)
     self.assertEqual(data[0]['name'], "dbserver")
Example #4
0
 def test_load_data_nodes(self):
     """Should return nodes when the given argument is 'nodes'"""
     data = chef._load_data('nodes')
     self.assertEqual(len(data), TOTAL_NODES)
     self.assertTrue(data[1]['name'].startswith('testnode'))
Example #5
0
 def test_incomplete_node_data_bag(self):
     """Should raise RepoError when a node is missing its data bag item"""
     nodes = chef._load_data("nodes")
     nodes.append({'name': 'extra_node'})
     self.assertRaises(chef.RepoError, chef._load_extended_node_data, nodes)
Example #6
0
 def test_missing_node_data_bag(self):
     """Should raise RepoError when there is no node data bag"""
     nodes = chef._load_data("nodes")
     with patch('kitchen.backends.lchef.DATA_BAG_PATH', 'badpath'):
         self.assertRaises(chef.RepoError, chef._load_extended_node_data,
                           nodes)