'Test update_project_cascade.
Ensures the enabled attribute is correctly updated across
a simple 3-level projects hierarchy.'

def test_update_project_enabled_cascade(self):

    projects_hierarchy = self._create_projects_hierarchy(hierarchy_size=3)
    parent = projects_hierarchy[0]
    parent['enabled'] = False
    parent_ref = self.resource_api.update_project(parent['id'], parent, cascade=True)
    subtree = self.resource_api.list_projects_in_subtree(parent['id'])
    self.assertEqual(2, len(subtree))
    self.assertFalse(parent_ref['enabled'])
    self.assertFalse(subtree[0]['enabled'])
    self.assertFalse(subtree[1]['enabled'])
    parent['enabled'] = True
    parent_ref = self.resource_api.update_project(parent['id'], parent, cascade=True)
    subtree = self.resource_api.list_projects_in_subtree(parent['id'])
    self.assertEqual(2, len(subtree))
    self.assertTrue(parent_ref['enabled'])
    self.assertTrue(subtree[0]['enabled'])
    self.assertTrue(subtree[1]['enabled'])
