def setUp(self) -> None:
     super().setUp()
     self.action = MotionDelete(PermissionTestAdapter(),
                                DatabaseTestAdapter())
     self.user_id = (
         7826715669  # This user has perm MOTION_CAN_MANAGE for some meetings.
     )
Esempio n. 2
0
 def setUp(self) -> None:
     super().setUp()
     self.user_id = 7826715669
     self.action = MotionDelete(
         "motion.delete",
         PermissionTestAdapter(superuser=self.user_id),
         DatabaseTestAdapter(old_style_testing=True),
     )
Esempio n. 3
0
class MotionDeleteActionPerformTester(BaseMotionDeleteActionTester):
    def setUp(self) -> None:
        super().setUp()
        self.user_id = 7826715669
        self.action = MotionDelete(
            "motion.delete",
            PermissionTestAdapter(superuser=self.user_id),
            DatabaseTestAdapter(old_style_testing=True),
        )

    def test_perform_correct_1(self) -> None:
        write_request_elements = self.action.perform(self.valid_payload_1,
                                                     user_id=self.user_id)
        expected = [
            {
                "events": [
                    {
                        "type": "delete",
                        "fqid": get_fqid("motion/2995885358")
                    },
                    {
                        "type": "update",
                        "fqid": get_fqid("motion_block/4116433002"),
                        "fields": {
                            "motion_ids": []
                        },
                    },
                    {
                        "type": "update",
                        "fqid": get_fqid("motion_category/8734727380"),
                        "fields": {
                            "motion_ids": []
                        },
                    },
                    {
                        "type": "update",
                        "fqid": get_fqid("meeting/5562405520"),
                        "fields": {
                            "motion_ids": []
                        },
                    },
                    {
                        "type": "update",
                        "fqid": get_fqid("motion_state/5205893377"),
                        "fields": {
                            "motion_recommendation_ids": []
                        },
                    },
                    {
                        "type": "update",
                        "fqid": get_fqid("motion_state/5205893377"),
                        "fields": {
                            "motion_ids": []
                        },
                    },
                    {
                        "type": "update",
                        "fqid":
                        get_fqid("motion_statute_paragraph/8264607531"),
                        "fields": {
                            "motion_ids": []
                        },
                    },
                ],
                "information": {
                    get_fqid("motion/2995885358"): ["Object deleted"],
                    get_fqid("meeting/5562405520"):
                    ["Object attachment to motion reset"],
                    get_fqid("motion_statute_paragraph/8264607531"):
                    ["Object attachment to motion reset"],
                    get_fqid("motion_state/5205893377"): [
                        "Object attachment to motion reset",
                        "Object attachment to motion reset",
                    ],
                    get_fqid("motion_category/8734727380"):
                    ["Object attachment to motion reset"],
                    get_fqid("motion_block/4116433002"):
                    ["Object attachment to motion reset"],
                },
                "user_id":
                self.user_id,
            },
        ]
        self.assertEqual(
            list(write_request_elements),
            expected,
        )
Esempio n. 4
0
class MotionDeleteActionUnitTester(BaseMotionDeleteActionTester):
    def setUp(self) -> None:
        super().setUp()
        user_id = 7826715669
        self.action = MotionDelete(
            "motion.delete",
            PermissionTestAdapter(superuser=user_id),
            DatabaseTestAdapter(old_style_testing=True),
        )
        self.action.user_id = user_id

    def test_validation_correct_1(self) -> None:
        self.action.validate(self.valid_payload_1)

    def test_prepare_dataset_1(self) -> None:
        dataset = self.action.prepare_dataset(self.valid_payload_1)
        expected = [{
            "instance": {
                "id": self.valid_payload_1[0]["id"],
                "meeting_id": None,
                "statute_paragraph_id": None,
                "sort_parent_id": None,
                "lead_motion_id": None,
                "category_id": None,
                "block_id": None,
                "origin_id": None,
                "state_id": None,
                "recommendation_id": None,
                "supporter_ids": None,
                "attachment_ids": None,
                "tag_ids": None,
                "amendment_ids": None,
                "derived_motion_ids": None,
                "sort_child_ids": None,
            },
            "relations": {
                get_fqfield("meeting/5562405520/motion_ids"): {
                    "type": "remove",
                    "value": [],
                },
                get_fqfield("motion_statute_paragraph/8264607531/motion_ids"):
                {
                    "type": "remove",
                    "value": [],
                },
                get_fqfield("motion_state/5205893377/motion_ids"): {
                    "type": "remove",
                    "value": [],
                },
                get_fqfield("motion_state/5205893377/motion_recommendation_ids"):
                {
                    "type": "remove",
                    "value": [],
                },
                get_fqfield("motion_category/8734727380/motion_ids"): {
                    "type": "remove",
                    "value": [],
                },
                get_fqfield("motion_block/4116433002/motion_ids"): {
                    "type": "remove",
                    "value": [],
                },
            },
        }]
        self.maxDiff = None
        self.assertEqual(dataset["data"], expected)
class MotionDeleteActionPerformTester(BaseMotionDeleteActionTester):
    def setUp(self) -> None:
        super().setUp()
        self.action = MotionDelete(PermissionTestAdapter(),
                                   DatabaseTestAdapter())
        self.user_id = (
            7826715669  # This user has perm MOTION_CAN_MANAGE for some meetings.
        )

    def test_perform_correct_1(self) -> None:
        write_request_elements = self.action.perform(self.valid_payload_1,
                                                     user_id=self.user_id)
        expected = [
            {
                "events": [
                    {
                        "type": "delete",
                        "fqid": get_fqid("motion/2995885358")
                    },
                    {
                        "type": "update",
                        "fqid": get_fqid("motion_block/4116433002"),
                        "fields": {
                            "motion_ids": []
                        },
                    },
                    {
                        "type": "update",
                        "fqid": get_fqid("motion_category/8734727380"),
                        "fields": {
                            "motion_ids": []
                        },
                    },
                    {
                        "type": "update",
                        "fqid": get_fqid("meeting/5562405520"),
                        "fields": {
                            "motion_ids": []
                        },
                    },
                    {
                        "type": "update",
                        "fqid": get_fqid("motion_state/5205893377"),
                        "fields": {
                            "motion_recommendation_ids": []
                        },
                    },
                    {
                        "type": "update",
                        "fqid": get_fqid("motion_state/5205893377"),
                        "fields": {
                            "motion_ids": []
                        },
                    },
                    {
                        "type": "update",
                        "fqid":
                        get_fqid("motion_statute_paragraph/8264607531"),
                        "fields": {
                            "motion_ids": []
                        },
                    },
                ],
                "information": {
                    get_fqid("motion/2995885358"): ["Object deleted"],
                    get_fqid("meeting/5562405520"):
                    ["Object attachment to motion reset"],
                    get_fqid("motion_statute_paragraph/8264607531"):
                    ["Object attachment to motion reset"],
                    get_fqid("motion_state/5205893377"): [
                        "Object attachment to motion reset",
                        "Object attachment to motion reset",
                    ],
                    get_fqid("motion_category/8734727380"):
                    ["Object attachment to motion reset"],
                    get_fqid("motion_block/4116433002"):
                    ["Object attachment to motion reset"],
                },
                "user_id":
                self.user_id,
                "locked_fields": {
                    get_fqfield("motion/2995885358/deleted"):
                    1,
                    get_fqfield("meeting/5562405520/motion_ids"):
                    1,
                    get_fqfield("motion_statute_paragraph/8264607531/motion_ids"):
                    1,
                    get_fqfield("motion_state/5205893377/motion_ids"):
                    1,
                    get_fqfield("motion_state/5205893377/motion_recommendation_ids"):
                    1,
                    get_fqfield("motion_category/8734727380/motion_ids"):
                    1,
                    get_fqfield("motion_block/4116433002/motion_ids"):
                    1,
                },
            },
        ]
        self.assertEqual(
            list(write_request_elements),
            expected,
        )