def test_delete_project_group(self):

    class FakeItem(object):

        def __init__(self, name, id):
            self.name = name
            self.id = id
    conf = dummy_conf()
    patches = [patch('storyboardclient.v1.project_groups.ProjectGroupsManager.get_all'), patch('storyboardclient.v1.project_groups.ProjectGroupsManager.get'), patch('storyboardclient.v1.project_groups.ProjectGroupsManager.update'), patch('storyboardclient.v1.project_groups.ProjectGroupsManager.delete')]
    with nested(*patches) as (get_all, get, update, delete):
        s = StoryboardOps(conf, None)
        get_all.return_value = [FakeItem('pg1', 3)]
        mdelete = Mock()
        fake_subprojects = [FakeItem('project1', 1), FakeItem('project2', 2)]

        class fprojects():

            def get_all(self):
                return fake_subprojects

            def delete(self, id):
                mdelete(id)

        class NestedProjects():

            def __init__(self):
                self.projects = fprojects()
        get.return_value = NestedProjects()
        update.return_value = NestedProjects()
        s.delete_project_groups(**{'name': 'pg1'})
        self.assertEqual(len(mdelete.call_args_list), 2)
        self.assertIn(call(1), mdelete.call_args_list)
        self.assertIn(call(2), mdelete.call_args_list)
        self.assertListEqual(delete.call_args_list, [call(id=3)])
def test_delete_project_group(self):

    class FakeItem(object):

        def __init__(self, name, id):
            self.name = name
            self.id = id
    conf = dummy_conf()
    patches = [patch('storyboardclient.v1.project_groups.ProjectGroupsManager.get_all'), patch('storyboardclient.v1.project_groups.ProjectGroupsManager.get'), patch('storyboardclient.v1.project_groups.ProjectGroupsManager.update'), patch('storyboardclient.v1.project_groups.ProjectGroupsManager.delete')]
    with nested(*patches) as (get_all, get, update, delete):
        s = StoryboardOps(conf, None)
        get_all.return_value = [FakeItem('pg1', 3)]
        mdelete = Mock()
        fake_subprojects = [FakeItem('project1', 1), FakeItem('project2', 2)]

        class fprojects():

            def get_all(self):
                return fake_subprojects

            def delete(self, id):
                mdelete(id)

        class NestedProjects():

            def __init__(self):
                self.projects = fprojects()
        get.return_value = NestedProjects()
        update.return_value = NestedProjects()
        s.delete_project_groups(**{'name': 'pg1'})
        self.assertEqual(len(mdelete.call_args_list), 2)
        self.assertIn(call(1), mdelete.call_args_list)
        self.assertIn(call(2), mdelete.call_args_list)
        self.assertListEqual(delete.call_args_list, [call(id=3)])