def test_get_direct_children_of_menu(self):
     menus = {
         1: {
             'id': 1,
             'data': 'a',
             'child_ids': []
         },
         2: {
             'id': 2,
             'data': 'b',
             'child_ids': [1]
         },
         3: {
             'id': 3,
             'data': 'c',
             'child_ids': [4]
         },
         4: {
             'id': 4,
             'data': 'd',
             'child_ids': []
         }
     }
     self.assertCountEqual([], get_children_of_menu(menus, 1))
     self.assertIn(1, get_children_of_menu(menus, 2))
     self.assertIn(4, get_children_of_menu(menus, 3))
     self.assertCountEqual([], get_children_of_menu(menus, 4))
    def test_get_children_of_menu_with_diamond_cycle_to_self(self):
        menus = {
            1: {
                'id': 1,
                'data': 'a',
                'child_ids': [2, 3]
            },
            2: {
                'id': 2,
                'data': 'b',
                'child_ids': [4]
            },
            3: {
                'id': 3,
                'data': 'c',
                'child_ids': [4]
            },
            4: {
                'id': 4,
                'data': 'd',
                'child_ids': [1]
            }
        }

        self.assertCountEqual([1, 2, 3, 4], get_children_of_menu(menus, 1))
        self.assertCountEqual([1, 2, 3, 4], get_children_of_menu(menus, 2))
        self.assertCountEqual([1, 2, 3, 4], get_children_of_menu(menus, 3))
        self.assertCountEqual([1, 2, 3, 4], get_children_of_menu(menus, 4))
 def test_get_children_of_menu_cycling_to_self_indirectly(self):
     menus = {
         1: {
             'id': 1,
             'data': 'a',
             'child_ids': [2]
         },
         2: {
             'id': 2,
             'data': 'b',
             'child_ids': [1]
         }
     }
     self.assertCountEqual([1, 2], get_children_of_menu(menus, 1))
     self.assertCountEqual([1, 2], get_children_of_menu(menus, 2))
 def test_get_children_of_menu_recursively(self):
     menus = {
         1: {
             'id': 1,
             'data': 'a',
             'child_ids': [2]
         },
         2: {
             'id': 2,
             'data': 'b',
             'child_ids': [3]
         },
         3: {
             'id': 3,
             'data': 'c',
             'child_ids': []
         },
     }
     self.assertCountEqual([2, 3], get_children_of_menu(menus, 1))
     self.assertCountEqual([3], get_children_of_menu(menus, 2))
     self.assertCountEqual([], get_children_of_menu(menus, 3))
 def test_get_children_of_menu_cycling_to_self(self):
     menus = {1: {'id': 1, 'data': 'a', 'child_ids': [1]}}
     self.assertCountEqual([1], get_children_of_menu(menus, 1))