Пример #1
0
    def update(self):
        """ Fetches the different kinds of risks we are interested in.

            Actioned Nodes
            --------------
            Title: "Risks that have been identified, evaluated and have an
            Action Plan"

            Unactioned Nodes
            ----------------
            Title: "Risks that have been identified but do NOT have an Action
            Plan"

            Unanswered Nodes
            ----------------
            Title: "Hazards/problems that have been "parked" and are still
            to be dealt with"

            Risk not present nodes
            ----------------------
            Title: "Hazards/problems that have been managed or are not present
            in your organisation"
        """
        if survey.redirectOnSurveyUpdate(self.request):
            return

        super(OSHAActionPlanReportDownload, self).update()
        # Returns all identified nodes, with or without action plans
        self.nodes = self.getNodes()

        # Get the extra attributes as per #1517, #1518:
        self.actioned_nodes = utils.get_actioned_nodes(self.nodes)

        self.unactioned_nodes = utils.get_unactioned_nodes(self.nodes)

        self.unanswered_nodes = utils.get_unanswered_nodes(self.session)
        risk_not_present_nodes = utils.get_risk_not_present_nodes(self.session)
        # From the non-present risks, filter out risks from the (un-)/actioned
        # categories. A "priority" risk will always appear in the action plan,
        # even if it has been answered with "Yes"
        self.risk_not_present_nodes = [
            n for n in risk_not_present_nodes if
            n not in self.actioned_nodes and n not in self.unactioned_nodes
        ]

        lang = getattr(self.request, 'LANGUAGE', 'en')
        if "-" in lang:
            elems = lang.split("-")
            lang = "{0}_{1}".format(elems[0], elems[1].upper())
        self.title_custom_risks = translate(_(
            'title_other_risks', default=u'Added risks (by you)'),
            target_language=lang)
Пример #2
0
    def update(self):
        """ Fetches the different kinds of risks we are interested in.

            Actioned Nodes
            --------------
            Title: "Risks that have been identified, evaluated and have an
            Action Plan"

            Unactioned Nodes
            ----------------
            Title: "Risks that have been identified but do NOT have an Action
            Plan"

            Unanswered Nodes
            ----------------
            Title: "Hazards/problems that have been "parked" and are still
            to be dealt with"

            Risk not present nodes
            ----------------------
            Title: "Hazards/problems that have been managed or are not present
            in your organisation"
        """
        if survey.redirectOnSurveyUpdate(self.request):
            return

        super(OSHAActionPlanReportDownload, self).update()
        # Returns all identified nodes, with or without action plans
        self.nodes = self.getNodes()

        # Get the extra attributes as per #1517, #1518:
        self.actioned_nodes = utils.get_actioned_nodes(self.nodes)

        self.unactioned_nodes = utils.get_unactioned_nodes(self.nodes)

        self.unanswered_nodes = utils.get_unanswered_nodes(self.session)
        risk_not_present_nodes = utils.get_risk_not_present_nodes(self.session)
        # From the non-present risks, filter out risks from the (un-)/actioned
        # categories. A "priority" risk will always appear in the action plan,
        # even if it has been answered with "Yes"
        self.risk_not_present_nodes = [
            n for n in risk_not_present_nodes
            if n not in self.actioned_nodes and n not in self.unactioned_nodes
        ]

        lang = getattr(self.request, 'LANGUAGE', 'en')
        if "-" in lang:
            elems = lang.split("-")
            lang = "{0}_{1}".format(elems[0], elems[1].upper())
        self.title_custom_risks = translate(_('title_other_risks',
                                              default=u'Added risks (by you)'),
                                            target_language=lang)
Пример #3
0
    def testUnactionedNodes(self):
        self.createData()

        interface.alsoProvides(self.portal.REQUEST, IReportPhaseSkinLayer)
        view = component.getMultiAdapter(
            (PathGhost('dummy'), self.portal.REQUEST), name="download")

        view.session = self.survey_session
        if view.session.company is None:
            self.session.company = model.Company()

        nodes = view.getNodes()
        self.assertEqual(len(utils.get_unactioned_nodes(nodes)), 3)
Пример #4
0
    def testUnactionedNodes(self):
        self.createData()

        interface.alsoProvides(self.portal.REQUEST, IReportPhaseSkinLayer)
        view = component.getMultiAdapter(
            (PathGhost('dummy'), self.portal.REQUEST), name="download")

        view.session = self.survey_session
        if view.session.company is None:
            self.session.company = model.Company()

        nodes = view.getNodes()
        self.assertEqual(len(utils.get_unactioned_nodes(nodes)), 3)
Пример #5
0
    def update(self):
        """ Fetches the different kinds of risks we are interested in.

            Actioned Nodes
            --------------
            Title: "Risks that have been identified, evaluated and have an
            Action Plan"

            Unactioned Nodes
            ----------------
            Title: "Risks that have been identified but do NOT have an Action
            Plan"

            Unanswered Nodes
            ----------------
            Title: "Hazards/problems that have been "parked" and are still
            to be dealt with"

            Risk not present nodes
            ----------------------
            Title: "Hazards/problems that have been managed or are not present
            in your organisation"
        """
        if survey.redirectOnSurveyUpdate(self.request):
            return

        super(OSHAActionPlanReportDownload, self).update()
        self.nodes = self.getNodes()  # Returns all identified nodes, with or
                                      # without action plans

        # Get the extra attributes as per #1517, #1518:
        self.actioned_nodes = utils.get_actioned_nodes(self.nodes)

        self.unactioned_nodes = utils.get_unactioned_nodes(self.nodes)

        self.unanswered_nodes = utils.get_unanswered_nodes(self.session)
        self.risk_not_present_nodes = \
            utils.get_risk_not_present_nodes(self.session)
Пример #6
0
    def test_utils_methods(self):
        """ Tests the following methods in osha.oira/utils.py:
                remove_empty_modules(ls)
                get_unactioned_nodes(ls)
                get_actioned_nodes(ls)
        """
        m = MockModule
        r = MockRisk
        ap = MockActionPlan('dummy')

        # Test a few variations of unactioned risks:
        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 0),
            r('1.2', '001002', 0),
            m('2', '002', 1),
            m('2.1', '002001', 2),
            m('2.1.1', '002001001', 3),
            r(
                '2.1.1.1',
                '002001001001',
                0,
            )
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes],
                          ['1', '1.1', '1.2', '2', '2.1', '2.1.1', '2.1.1.1'])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 0),
            r('1.2', '001002', 0),
            m('2', '002', 1),
            m('2.1', '002001', 2),
            m('2.1.1', '002001001', 3),
            r('2.1.1.1', '002001001001', 0, [ap])
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes],
                          ['1', '1.1', '1.2'])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 0),
            r('1.2', '001002', 0),
            m('2', '002', 1),
            m('2.1', '002001', 2),
            m('2.1.1', '002001001', 3),
            r('2.1.1.1', '002001001001', 9, [ap])
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes],
                          ['1', '1.1', '1.2'])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 3, [ap]),
            r('1.2', '001002', 2, [ap]),
            m('2', '002', 1),
            m('2.1', '002001', 2),
            m('2.1.1', '002001001', 3),
            r('2.1.1.1', '002001001001', 0, [ap])
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], [])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 2, [ap]),
            r('1.2', '001002', 3, [ap]),
            m('2', '002', 1),
            m('3', '003', 1),
            r('3', '003', 3)
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], ['3', '3'])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 0, [ap]),
            r('1.2', '001002', 3, [ap]),
            m('2', '002', 1),
            m('3', '003', 1),
            r('3.1', '003001', 3)
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], ['3', '3.1'])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 2, [ap]),
            r('1.2', '001002', 3, [ap]),
            m('2', '002', 1),
            m('3', '003', 1),
            r('3.1', '003001', 3, [ap])
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], [])

        # Test a few variations of actioned risks:
        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 0),
            r('1.2', '001002', 0),
            m('2', '002', 1),
            m('2.1', '002001', 2),
            m('2.1.1', '002001001', 3),
            r('2.1.1.1', '002001001001', 0, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes],
                          ['2', '2.1', '2.1.1', '2.1.1.1'])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 0),
            r('1.2', '001002', 0),
            m('2', '002', 1),
            m('2.1', '002001', 2),
            m('2.1.1', '002001001', 3),
            r('2.1.1.1', '002001001001', 9, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes],
                          ['2', '2.1', '2.1.1', '2.1.1.1'])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 3, [ap]),
            r('1.2', '001002', 2, [ap]),
            m('2', '002', 1),
            m('2.1', '002001', 2),
            m('2.1.1', '002001001', 3),
            r('2.1.1.1', '002001001001', 0, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes],
                          ['1', '1.1', '1.2', '2', '2.1', '2.1.1', '2.1.1.1'])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 2, [ap]),
            r('1.2', '001002', 3, [ap]),
            m('2', '002', 1),
            m('3', '003', 1),
            r('3.1', '003001', 3)
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes], ['1', '1.1', '1.2'])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 0, [ap]),
            r('1.2', '001002', 3, [ap]),
            m('2', '002', 1),
            m('3', '003', 1),
            r('3.1', '003001', 3, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes],
                          ['1', '1.1', '1.2', '3', '3.1'])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 2, [ap]),
            r('1.2', '001002', 3, [ap]),
            m('2', '002', 1),
            m('2.1', '002001', 2),
            r('2.1.1', '002001001', 3, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes],
                          ['1', '1.1', '1.2', '2', '2.1', '2.1.1'])

        nodes = [
            m('1', '001', 1),
            m('1.1', '001001', 2),
            r('1.1.1', '001001001', 3, [ap]),
            m('1.2', '001002', 2),
            m('1.2.1', '001002001', 3),
            r('1.2.1.1', '001002001001', 4),
            m('2', '002', 1),
            m('2.1', '002001', 2),
            m('2.1.1', '002001001', 3),
            r('2.1.1.1', '002001001001', 0, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ['1', '1.1', '1.1.1', '2', '2.1', '2.1.1', '2.1.1.1'])

        # Issue 3265
        nodes = [
            m('1', '001', 1),
            m('1.1', '001001', '002'),
            r('1.1.1', '001001001', 3),
            m('2', '002', 1),
            m('2.1', '002001', '002'),
            r('2.1.1', '002001001', 3, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes],
                          ['2', '2.1', '2.1.1'])

        nodes = [
            m('1', '001', 1),
            m('1.1', '001001', '002'),
            m('1.1.1', '001001001', 3),
            m('2', '002', 1),
            m('2.1', '002001', '002'),
            r('2.1.1', '002001001', 3, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes],
                          ['2', '2.1', '2.1.1'])

        nodes = [
            m('1', '001', 1),
            m('1.1', '001001', '002'),
            r('1.1.1', '001001001', 3, [ap]),
            m('2', '002', 1),
            m('2.1', '002001', '002'),
            r('2.1.1', '002001001', 3)
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes],
                          ['1', '1.1', '1.1.1'])

        nodes = [
            m('1', '001', 1),
            m('1.1', '001001', '002'),
            r('1.1.1', '001001001', 3),
            m('2', '002', 1),
            m('2.1', '002001', '002'),
            r('2.1.1', '002001001', 3)
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes], [])
Пример #7
0
    def test_utils_methods(self):
        """Tests the following methods in osha.oira/utils.py:
        remove_empty_modules(ls)
        get_unactioned_nodes(ls)
        get_actioned_nodes(ls)
        """
        m = MockModule
        r = MockRisk
        ap = MockActionPlan("dummy")

        # Test a few variations of unactioned risks:
        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 0),
            r("1.2", "001002", 0),
            m("2", "002", 1),
            m("2.1", "002001", 2),
            m("2.1.1", "002001001", 3),
            r(
                "2.1.1.1",
                "002001001001",
                0,
            ),
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in unactioned_nodes],
            ["1", "1.1", "1.2", "2", "2.1", "2.1.1", "2.1.1.1"],
        )

        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 0),
            r("1.2", "001002", 0),
            m("2", "002", 1),
            m("2.1", "002001", 2),
            m("2.1.1", "002001001", 3),
            r("2.1.1.1", "002001001001", 0, [ap]),
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], ["1", "1.1", "1.2"])

        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 0),
            r("1.2", "001002", 0),
            m("2", "002", 1),
            m("2.1", "002001", 2),
            m("2.1.1", "002001001", 3),
            r("2.1.1.1", "002001001001", 9, [ap]),
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], ["1", "1.1", "1.2"])

        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 3, [ap]),
            r("1.2", "001002", 2, [ap]),
            m("2", "002", 1),
            m("2.1", "002001", 2),
            m("2.1.1", "002001001", 3),
            r("2.1.1.1", "002001001001", 0, [ap]),
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], [])

        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 2, [ap]),
            r("1.2", "001002", 3, [ap]),
            m("2", "002", 1),
            m("3", "003", 1),
            r("3", "003", 3),
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], ["3", "3"])

        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 0, [ap]),
            r("1.2", "001002", 3, [ap]),
            m("2", "002", 1),
            m("3", "003", 1),
            r("3.1", "003001", 3),
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], ["3", "3.1"])

        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 2, [ap]),
            r("1.2", "001002", 3, [ap]),
            m("2", "002", 1),
            m("3", "003", 1),
            r("3.1", "003001", 3, [ap]),
        ]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], [])

        # Test a few variations of actioned risks:
        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 0),
            r("1.2", "001002", 0),
            m("2", "002", 1),
            m("2.1", "002001", 2),
            m("2.1.1", "002001001", 3),
            r("2.1.1.1", "002001001001", 0, [ap]),
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes], ["2", "2.1", "2.1.1", "2.1.1.1"]
        )

        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 0),
            r("1.2", "001002", 0),
            m("2", "002", 1),
            m("2.1", "002001", 2),
            m("2.1.1", "002001001", 3),
            r("2.1.1.1", "002001001001", 9, [ap]),
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes], ["2", "2.1", "2.1.1", "2.1.1.1"]
        )

        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 3, [ap]),
            r("1.2", "001002", 2, [ap]),
            m("2", "002", 1),
            m("2.1", "002001", 2),
            m("2.1.1", "002001001", 3),
            r("2.1.1.1", "002001001001", 0, [ap]),
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ["1", "1.1", "1.2", "2", "2.1", "2.1.1", "2.1.1.1"],
        )

        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 2, [ap]),
            r("1.2", "001002", 3, [ap]),
            m("2", "002", 1),
            m("3", "003", 1),
            r("3.1", "003001", 3),
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes], ["1", "1.1", "1.2"])

        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 0, [ap]),
            r("1.2", "001002", 3, [ap]),
            m("2", "002", 1),
            m("3", "003", 1),
            r("3.1", "003001", 3, [ap]),
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes], ["1", "1.1", "1.2", "3", "3.1"]
        )

        nodes = [
            m("1", "001", 1),
            r("1.1", "001001", 2, [ap]),
            r("1.2", "001002", 3, [ap]),
            m("2", "002", 1),
            m("2.1", "002001", 2),
            r("2.1.1", "002001001", 3, [ap]),
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes], ["1", "1.1", "1.2", "2", "2.1", "2.1.1"]
        )

        nodes = [
            m("1", "001", 1),
            m("1.1", "001001", 2),
            r("1.1.1", "001001001", 3, [ap]),
            m("1.2", "001002", 2),
            m("1.2.1", "001002001", 3),
            r("1.2.1.1", "001002001001", 4),
            m("2", "002", 1),
            m("2.1", "002001", 2),
            m("2.1.1", "002001001", 3),
            r("2.1.1.1", "002001001001", 0, [ap]),
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ["1", "1.1", "1.1.1", "2", "2.1", "2.1.1", "2.1.1.1"],
        )

        # Issue 3265
        nodes = [
            m("1", "001", 1),
            m("1.1", "001001", "002"),
            r("1.1.1", "001001001", 3),
            m("2", "002", 1),
            m("2.1", "002001", "002"),
            r("2.1.1", "002001001", 3, [ap]),
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes], ["2", "2.1", "2.1.1"])

        nodes = [
            m("1", "001", 1),
            m("1.1", "001001", "002"),
            m("1.1.1", "001001001", 3),
            m("2", "002", 1),
            m("2.1", "002001", "002"),
            r("2.1.1", "002001001", 3, [ap]),
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes], ["2", "2.1", "2.1.1"])

        nodes = [
            m("1", "001", 1),
            m("1.1", "001001", "002"),
            r("1.1.1", "001001001", 3, [ap]),
            m("2", "002", 1),
            m("2.1", "002001", "002"),
            r("2.1.1", "002001001", 3),
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes], ["1", "1.1", "1.1.1"])

        nodes = [
            m("1", "001", 1),
            m("1.1", "001001", "002"),
            r("1.1.1", "001001001", 3),
            m("2", "002", 1),
            m("2.1", "002001", "002"),
            r("2.1.1", "002001001", 3),
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes], [])
Пример #8
0
    def test_utils_methods(self):
        """ Tests the following methods in osha.oira/utils.py:
                remove_empty_modules(ls)
                get_unactioned_nodes(ls)
                get_actioned_nodes(ls)
        """
        m = MockModule
        r = MockRisk
        ap = MockActionPlan('dummy')

        # Test a few variations of unactioned risks:
        nodes = [m('1', '001', 1),
                 r('1.1', '001001', 0),
                 r('1.2', '001002', 0),
                 m('2', '002', 1),
                 m('2.1', '002001', 2),
                 m('2.1.1', '002001001', 3),
                 r('2.1.1.1', '002001001001', 0, )]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in unactioned_nodes],
            ['1', '1.1', '1.2', '2', '2.1', '2.1.1', '2.1.1.1']
        )

        nodes = [m('1', '001', 1),
                 r('1.1', '001001', 0),
                 r('1.2', '001002', 0),
                 m('2', '002', 1),
                 m('2.1', '002001', 2),
                 m('2.1.1', '002001001', 3),
                 r('2.1.1.1', '002001001001', 0, [ap])]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in unactioned_nodes],
            ['1', '1.1', '1.2']
        )

        nodes = [m('1', '001', 1),
                 r('1.1', '001001', 0),
                 r('1.2', '001002', 0),
                 m('2', '002', 1),
                 m('2.1', '002001', 2),
                 m('2.1.1', '002001001', 3),
                 r('2.1.1.1', '002001001001', 9, [ap])]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in unactioned_nodes],
            ['1', '1.1', '1.2']
        )

        nodes = [m('1', '001', 1),
                 r('1.1', '001001', 3, [ap]),
                 r('1.2', '001002', 2, [ap]),
                 m('2', '002', 1),
                 m('2.1', '002001', 2),
                 m('2.1.1', '002001001', 3),
                 r('2.1.1.1', '002001001001', 0, [ap])]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], [])

        nodes = [m('1', '001', 1),
                 r('1.1', '001001', 2, [ap]),
                 r('1.2', '001002', 3, [ap]),
                 m('2', '002', 1),
                 m('3', '003', 1),
                 r('3', '003', 3)]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], ['3', '3'])

        nodes = [m('1', '001', 1),
                 r('1.1', '001001', 0, [ap]),
                 r('1.2', '001002', 3, [ap]),
                 m('2', '002', 1),
                 m('3', '003', 1),
                 r('3.1', '003001', 3)]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], ['3', '3.1'])

        nodes = [m('1', '001', 1),
                 r('1.1', '001001', 2, [ap]),
                 r('1.2', '001002', 3, [ap]),
                 m('2', '002', 1),
                 m('3', '003', 1),
                 r('3.1', '003001', 3, [ap])]
        unactioned_nodes = utils.get_unactioned_nodes(nodes)
        self.assertEquals([n.id for n in unactioned_nodes], [])

        # Test a few variations of actioned risks:
        nodes = [m('1', '001', 1),
                 r('1.1', '001001', 0),
                 r('1.2', '001002', 0),
                 m('2', '002', 1),
                 m('2.1', '002001', 2),
                 m('2.1.1', '002001001', 3),
                 r('2.1.1.1', '002001001001', 0, [ap])]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ['2', '2.1', '2.1.1', '2.1.1.1']
        )

        nodes = [m('1', '001', 1),
                 r('1.1', '001001', 0),
                 r('1.2', '001002', 0),
                 m('2', '002', 1),
                 m('2.1', '002001', 2),
                 m('2.1.1', '002001001', 3),
                 r('2.1.1.1', '002001001001', 9, [ap])]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ['2', '2.1', '2.1.1', '2.1.1.1']
        )

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 3, [ap]),
            r('1.2', '001002', 2, [ap]),
            m('2', '002', 1),
            m('2.1', '002001', 2),
            m('2.1.1', '002001001', 3),
            r('2.1.1.1', '002001001001', 0, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ['1', '1.1', '1.2', '2', '2.1', '2.1.1', '2.1.1.1']
        )

        nodes = [m('1', '001', 1),
                 r('1.1', '001001', 2, [ap]),
                 r('1.2', '001002', 3, [ap]),
                 m('2', '002', 1),
                 m('3', '003', 1),
                 r('3.1', '003001', 3)]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes], ['1', '1.1', '1.2'])

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 0, [ap]),
            r('1.2', '001002', 3, [ap]),
            m('2', '002', 1),
            m('3', '003', 1),
            r('3.1', '003001', 3, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ['1', '1.1', '1.2', '3', '3.1']
        )

        nodes = [
            m('1', '001', 1),
            r('1.1', '001001', 2, [ap]),
            r('1.2', '001002', 3, [ap]),
            m('2', '002', 1),
            m('2.1', '002001', 2),
            r('2.1.1', '002001001', 3, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ['1', '1.1', '1.2', '2', '2.1', '2.1.1']
        )

        nodes = [m('1', '001', 1),
                 m('1.1', '001001', 2),
                 r('1.1.1', '001001001', 3, [ap]),
                 m('1.2', '001002', 2),
                 m('1.2.1', '001002001', 3),
                 r('1.2.1.1', '001002001001', 4),
                 m('2', '002', 1),
                 m('2.1', '002001', 2),
                 m('2.1.1', '002001001', 3),
                 r('2.1.1.1', '002001001001', 0, [ap])]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ['1', '1.1', '1.1.1', '2', '2.1', '2.1.1', '2.1.1.1']
        )

        # Issue 3265
        nodes = [
            m('1', '001', 1),
            m('1.1', '001001', '002'),
            r('1.1.1', '001001001', 3),
            m('2', '002', 1),
            m('2.1', '002001', '002'),
            r('2.1.1', '002001001', 3, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ['2', '2.1', '2.1.1']
        )

        nodes = [
            m('1', '001', 1),
            m('1.1', '001001', '002'),
            m('1.1.1', '001001001', 3),
            m('2', '002', 1),
            m('2.1', '002001', '002'),
            r('2.1.1', '002001001', 3, [ap])
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ['2', '2.1', '2.1.1']
        )

        nodes = [
            m('1', '001', 1),
            m('1.1', '001001', '002'),
            r('1.1.1', '001001001', 3, [ap]),
            m('2', '002', 1),
            m('2.1', '002001', '002'),
            r('2.1.1', '002001001', 3)
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals(
            [n.id for n in actioned_nodes],
            ['1', '1.1', '1.1.1']
        )

        nodes = [
            m('1', '001', 1),
            m('1.1', '001001', '002'),
            r('1.1.1', '001001001', 3),
            m('2', '002', 1),
            m('2.1', '002001', '002'),
            r('2.1.1', '002001001', 3)
        ]
        actioned_nodes = utils.get_actioned_nodes(nodes)
        self.assertEquals([n.id for n in actioned_nodes], [])