Esempio n. 1
0
class MotionUpdateActionUnitTester(BaseMotionUpdateActionTester):
    def setUp(self) -> None:
        super().setUp()
        user_id = 7826715669
        self.action = MotionUpdate(
            "motion.update",
            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)
        instance = deepcopy(self.valid_payload_1[0])
        instance["last_modified"] = round(time.time())
        self.assertEqual(
            dataset["data"],
            [{
                "instance": instance,
                "relations": {
                    get_fqfield("motion_statute_paragraph/8264607531/motion_ids"):
                    {
                        "type": "remove",
                        "value": [],
                    }
                },
            }],
        )
class MotionUpdateActionUnitTester(BaseMotionUpdateActionTester):
    def setUp(self) -> None:
        super().setUp()
        self.action = MotionUpdate(PermissionTestAdapter(),
                                   DatabaseTestAdapter())
        self.action.user_id = (
            7826715669  # This user has perm MOTION_CAN_MANAGE for some meetings.
        )

    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)
        self.assertEqual(dataset["position"], 1)
        instance = deepcopy(self.valid_payload_1[0])
        instance["last_modified"] = round(time.time())
        self.assertEqual(
            dataset["data"],
            [{
                "instance": instance,
                "relations": {
                    get_fqfield("motion_statute_paragraph/8264607531/motion_ids"):
                    {
                        "type": "remove",
                        "value": [],
                    }
                },
            }],
        )